I have an android app that displays a list of items in a Custom ListView using checkb开发者_如何学Gooxes.I need to write a code that stores the checked and unchecked items locally on my phone or emulator(since now presently working on localhost). Is there any way to store the data locally on the phone. I have heard of SQLLite and SharedPreferences but I have an application made already and for me it would better using the same for storing the data rather than creating a separate code structure as in the case of SQLLite.
Also the data I am going to store, I plan to use it to send to a remote database via web services. So considering all this ,
Can anyone tell me how to go about using SharedPreferences for my application?
Here's my present android code : http://pastebin.com/VvVU5Lrb
I would convert the list to JSON string and save it in shared preferences, both operations are simple and the JSON format will allow a simple transfer and parsing of the data in the server side as well.
Here's a link for you
Using Shared Preferences
This should help.
Check this once. Here you will find the way how to use shared preferences and writing and reading values using shared preferences.
http://androidcodesnips.blogspot.com/2011/06/shared-preferences-persistent-storage.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Androidcodes+%28AndroidCodes%29
SharedPreferences is like creating session. It is good with small data such as username, email, password, etc. If you need to temporary store large data, I suggest sqlite instead. After the data has been manipulated, you can store in your mysql, or others by httprequest/response and php. (Maybe using List<NameValuePair> params = new ArrayList<NameValuePair>();
. . .)
精彩评论