问题描述
我正在寻找iPhone上的Keychain
之类的东西,但用于Android开发.有了这种功能,即使用户重新安装了应用程序,我也可以保存持久且不变的小键/值对.
I'm looking for something like the Keychain
on the iPhone, but for Android development. Something that gives me the capability to save small key-value pairs that are persistent and unchanged even if the user reinstalls the application.
有没有类似的东西?我可以那样使用标准首选项吗?
Is there something like that? Can I use the standard preferences that way?
我希望实现与PC上的游戏类似的行为-将保存文件写入另一个文件夹,以便在删除并重新安装后保存文件不会丢失.
I would like to achieve a behavior similar to the way it works with games on a PC - writing the save files to another folder so that after deletion and reinstallation the save files are not lost.
这笔赏金用完了,没有人提到accountManager
.我偶然发现了它.那会是一种实现我描述的行为的方法吗?
The bounty ran out without somebody mentioning the accountManager
. I just stumbled over it. Would that be a method to achieve the behaviour described by me?
推荐答案
您可以使用SD卡上的存储空间,就像Michael Cramer所说的(让用户知道您正在存储数据:-)).删除应用程序后,不会删除SD卡上的数据.
You you use storage on the SD card like Michael Cramer stated ( Let the user know you are storing data :-) ). The data on the SD card is not deleted when the app is removed.
另一方面,您可以使用存储所有详细信息的服务器,可以在需要时下载所有详细信息,并且可以使用唯一的手机IMEI代替用户名.这样,即使用户重新安装操作系统,他仍将能够重新获取设置.
You could on the other hand use a server which stores all the details which can be downloaded as and when required and instead of using a user name use the IMEI of the phone which is unique. That way even if the user reinstalls the OS he will still be able to refetch the settings.
有关获取IMEI的信息,请参阅:如何在Android中以编程方式获取设备的IMEI/ESN?
for getting the IMEI you may refer : How to get the device's IMEI/ESN programmatically in android?
这篇关于Android中是否有类似iPhone的钥匙串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!