handle large Parcelable ArrayList in Android
- by Gal Ben-Haim
I'm developing an Android app that is a client to a JSON webservice API.
I have classes of resource objects (some are nested) and I pass results from an IntentService that access the webserive using the Parcelable interface for all the resource classes.
the webservice returns arrays or results that can be potentially large (because of the nesting, for example, a post object also contains comments array, each comment also contains a user object).
currently I'm either inserting the results into a SQlite database or displaying them in a ListView. (my relevant methods are accepting ArrayList<resourceClass> as arguments).
(some data need to be persistent stored and some should not).
since I don't know what size of lists I can handle this way without reaching the memory limits, is this a good practice ?
is it a better idea to save the parsed JSON to a local file immediately and pass the file path to the ResultReceiver, then either insert to database from that file or display the data ?
is there a better way to handle this ?
btw - I'm parsing the JSON as a stream with Gson's Reader so there shouldn't be memory issues at that stage.