I have to download around 6000 records into the sqlite database from a server. The records are present as JSON
objects. While retrieving them using a BufferedReader
, i get an error as out of memory bound exception. I have searched many sites but could not find an appropriate answer. Please suggest some best solution.
My code is:
URL url = new URL("myurl");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
//getting error here
line = in.readLine();
System.out.println(line);
JSONArray outerArray = (JSONArray) JSONSerializer.toJSON(line);
System.out.println("size : " + outerArray.size());
I got this Fatal Exception -
E/AndroidRuntime(616): java.lang.OutOfMemoryError: [memory exhausted]