开发者

store data without using database in android

i have to make an android application in which i need to download a lot of data from the server which is sent to me via XML. i then need to parse the XML and then display the extracted information.

To avoid making the application slow, i have decided to break my XML down into small parts.. so that i can only call the part that i want, this would limit the information that i am receiving.

My question is once that i have parsed the开发者_JAVA百科 XML data where do i store it ( except for a db ) until my UI is rendered? On the iPhone there is something called user default where in we can store such information. What would be the equivalent in android?

thank you in advance.


Every thing you need should be right here: http://developer.android.com/guide/topics/data/data-storage.html. Internal storage is the closest to the iPhone equivalent.


You can use application preferences to store data as shown here (if the data is small enough).

Their code sample shows:

SharedPreferences gameSettings = getSharedPreferences("MyGamePreferences", MODE_PRIVATE);  
SharedPreferences.Editor prefEditor = gameSettings.edit();  
prefEditor.putString("UserName", "Guest123");  
prefEditor.commit(); 

I wouldn't do this for large datasets but it's a handy place to store data. This gets removed when the application is removed too.

If you've got a lot of data, I'd suggest storing it on disk.


  1. You could store it in a file.
  2. You could store it in SharedPreferences
  3. You could use a ContentProvider --> not recommended for temporary storage.
  4. You could use a SQLiteDB --> I know you said you do not want to use this.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜