是否有可能存储类的静态对象共享preference? [英] Is it possible to stored Class's static object in Shared Preference?
问题描述
我开发在我创建一个静态类的对象
的项目。所以,当我关闭设备,当时所有的静态对象将被清除
所以我要存储到共享preference
。这样我就可以再次使用。是否有可能将其保存在共享preference?
或任何其他可能使用该对象重启设备后?
I am developing a project in that i am creating one static class's object
. So when i switch off device at that time all the static objects are cleared
so i want to stored into shared preference
. So i can use it again . Is it possible to save it in shared preference?
Or any other possibility to use that object after restart device ?
推荐答案
您只能保存基本数据类型,如浮点数,整型,字符串,字符串集或布尔值。您可序列化对象的字节流,然后从字节流reacreate他们,你可以看看这个的答也是这个<一个href=\"http://stackoverflow.com/questions/1254644/how-to-store-an-object-into-a-sqlite-database-in-android\">Answer
You can only save primitive data types like float, int, string, set of strings or booleans. You can serialize your objects in byte stream and then reacreate them from the byte stream, you can have a look at this Answer also this Answer
这篇关于是否有可能存储类的静态对象共享preference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!