I want to save my downloaded ListView
items so that for example next time the app starts, it should not start my download dialog, instead my previous ListView
items should turn up.
Some useful code snippets would be appreciated.
Thanks in adv开发者_JAVA百科ance and please tell me if I need to clarify!
It depends on the kind of data that is displayed in your ListView.
You can store the data into a SQLite database. This means designing an appropriate schema and implementing create/read/update/delete methods.
The process is too long to be explained here in detail; I invite you to read the Notepad tutorial on the official Android developer site.
Depending on the amount of data you are saving you can have many options.
I am assuming you are starting out so it is probably best to go with a straight forward solution utilizing the SQLiteDB instead of preferences or saving to a file.
This is a link to a complete solution for creating the views adapters and database objects.
You could just cut and paste, but read through it and it will be better for you in the long run
Complete ListView Database Tutorial
Android SQLite Basics
List View loaded from XML Resource File
In order to do this, you need to think of a strategy for saving data. The most common one is through a SQLite Android DB, nevertheless you might also use Internal Storage if your data is not that complex. Also saving data on Android has been a common topic (check this post)
Have a look at the Java Serialization API. It has its drawbacks (concurrent access....), but maybe it's enough for you.
That's just a quick google hit for that topic. http://java.sun.com/javase/technologies/core/basic/serializationFAQ.jsp
You can use SharedPreferences
精彩评论