Title is a bit ambiguous, but what I mean is:
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
JSONArray ja = new JSONArray();
while((line = rd.readLine()) != null) {
ja = new JSONArray(line);
}
rd.close();
return ja;
}
If rd.readLine() returns a HUGE amount of data, how can I split it, or limit it? I’m getting an outofmemoryerror.
I see two options
1) Store it as part of App by adding it to assests
2) Redesign your data. Most of the times the data you are retrieving in this single call may not be useful at that perticular time. I would suggest split your data retrieval as needed basis. Because of Dalvik VM you don’t have options to increase heap-size, so you have to think of these alternatives to come out of this OutofMemoryError.