在共享首选项中存储和检索类对象 [英] store and retrieve a class object in shared preference

查看:37
本文介绍了在共享首选项中存储和检索类对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 中,我们可以在共享首选项中存储类的对象并稍后检索该对象吗?

In Android can we store an object of a class in shared preference and retrieve the object later?

如果有可能怎么做?如果这是不可能的,那么还有哪些其他可能性呢?

If it is possible how to do it? If it is not possible what are the other possibilities of doing it?

我知道序列化是一种选择,但我正在寻找使用共享首选项的可能性.

I know that serialization is one option, but I am looking for possibilities using shared preference.

推荐答案

不可能.

您只能在 SharedPrefences 中存储简单的值 SharePreferences.Editor

You can only store, simple values in SharedPrefences SharePreferences.Editor

您需要保存的课程有哪些特别之处?

What particularly about the class do you need to save?

这篇关于在共享首选项中存储和检索类对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆