handle large Parcelable ArrayList in Android

Posted by Gal Ben-Haim on Stack Overflow See other posts from Stack Overflow or by Gal Ben-Haim
Published on 2012-10-14T09:01:29Z Indexed on 2012/10/14 9:37 UTC
Read the original article Hit count: 219

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sqlite