iPhone-like Keychain in Android?

2020-02-09 06:50发布

I'm looking for something like the keychain on the iPhone, but for Android development.
Something that gives me the possibility 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?

I would like to achieve a behavior in a way it works with games on a PC writing the save games to another folder so that after delete and later reinstall they are not lost.

Edit

The bounty run out without somebody mentioning the accountManager. I just stumbled over it. Wouldn't that be a method to achieve the behaviour described by me?

4条回答
劳资没心,怎么记你
2楼-- · 2020-02-09 07:29

Since Android & iPhone-like phones will normally run with a data plan, I would suggest that you save your key-value pairs into a centralized server. When the app goes through the uninstall, followed by an install process, just resync it with your server.

查看更多
Emotional °昔
3楼-- · 2020-02-09 07:43

Yes. Preferences are persistant and will survive a normal application upgrade.

查看更多
看我几分像从前
4楼-- · 2020-02-09 07:45

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.

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.

for getting the IMEI you may refer : How to get the device's IMEI/ESN programmatically in android?

查看更多
等我变得足够好
5楼-- · 2020-02-09 07:45

You have the real thing here:

By integrating Smart Lock for Passwords into your Android app, you can automatically sign users in to your app using the credentials they have saved. Users can save both username-password credentials and federated identity provider credentials.

Integrate Smart Lock for Passwords into your app by using the Credentials API to retrieve saved credentials on sign-in. Use successfully retrieved credentials to sign the user in, or use the Credentials API to rapidly on-board new users by partially completing your app's sign in or sign up form. Prompt users after sign-in or sign-up to store their credentials for future automatic authentication.

https://developers.google.com/identity/smartlock-passwords/android/

查看更多
登录 后发表回答