简单的方法来保存在LinkedList的Android应用程序? [英] easy way to save a LinkedList in a Android Application?
问题描述
什么是保存在一个Android应用程序对象的列表中easyest或本机方式?
what is the easyest or native way to save a list of objects in a android application?
我需要保存它,然后将其加载应用程序时再次启动。
i need to save it and then load it when the app starts again.
将是不错的,也许有人有一个现成的使用库,这使得我的一切。
would be nice maybe someone have a ready to use library which makes everything for me.
推荐答案
让存储在的LinkedList
实施的 Parcelable
所以你可以把它们放在你的束
。该在 onSaveInstance
你可以把你的对象在包
使用:
Let your items stored in the LinkedList
implement Parcelable
so you can put them in your bundle
. The in onSaveInstance
you can put your objects in the bundle
using:
bundle.putParcelableArrayList ("key", list);
和 onRestoreInstanceState
的活动的
获取数据从包后退code>使用:
and in onRestoreInstanceState
of your Activity
get the data back from that bundle
using :
bundle.getParcelableArrayList();
这篇关于简单的方法来保存在LinkedList的Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!