I have a Listview that contains 100 rows. This is the first time I load all the data from a Webservice. I want to cache that data so that if I open that page I should get it from cache not from the Webservice. How can I do this?
If your data is simple enough, just store them in an array and use something like ArrayAdapter to bind the data to the list view.
If your data is more complex, then an SQLite table is probably preferable. In this case use something like SimpleCursorAdapter.
You can store the data as a JSON file in your application's internal storage space. I find that this is a much easier approach, as you can easily map the JSON to Model classes using a library like Gson. You would typically follow this approach if the data you have will not be "updated" like you might do in a traditional database(although you are still able to update your JSON data, just differently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With