由网友(遥不可及く)分享简介:我要储存一个自定义对象(我们称之为myObject的)永久,这样如果是从内存中删除,我可以在我的活动/片段,当应用程序再次启动重新装入onResume()方法。I want to store a custom object (let's call it MyObject) permanently so that if...
我要储存一个自定义对象(我们称之为myObject的)永久,这样如果是从内存中删除,我可以在我的活动/片段,当应用程序再次启动重新装入onResume()方法。
I want to store a custom object (let's call it MyObject) permanently so that if it is deleted from memory, I can reload it in my activity/fragment onResume() method when the app starts again.
我怎么能这样做?共享preferences似乎不具有用于存储parcelable对象的方法
How can I do that? SharedPreferences doesn't seem to have a method for storing parcelable objects.
推荐答案
您可以写你的捆绑
作为一个包裹到磁盘,然后拿到包裹
后,使用 Parcel.readBundle()
的方法来让你的捆绑
返回。
You can write your Bundle
as a parcel to disk, then get the Parcel
later and use the Parcel.readBundle()
method to get your Bundle
back.
相关推荐
最新文章