开发者

Adding values from a arrayList to shared Preference

Is it possible for me to store and retrieve my ArrayList values using shared preference. Can anyone suggest me wi开发者_Python百科th an example.


It looks like the closest the SharedPreferences can do is save a Set of Strings. If that doesn't suit you should probably look at the alternatives for persisting data.


You can refer to this : http://androidcodemonkey.blogspot.com/2011/07/store-and-get-object-in-android-shared.html (Thanks to Greg Zimmers that give this tutorial).

The idea is you encapsulate the ArrayList to an Object and then you can refer to link tutorial that I give above and follow the tutorial. If you want to retrieve the ArrayList, you can get the Object and then you retrieve the ArrayList from the Object.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜