Using the android Account Manager to keep a username even if the app is deleted
A month ago I asked this question. Even with a Bounty nobody came up with a better answer then using the Imei of the device to identify the user and then sync the phone wit开发者_开发问答h the server.
Now I stumbled across the Android AccountManager classes. Would it be possible to use this classes to store a username and a password that could be accessed after a delete/reeinstall cycle of my application?
If yes how would I do this? And would that require the user to enter its keystore credentials every time the application runs and the keystore isn't opened already?
I don't think so. In my experiments accounts are deleted if the package containing the authenticator that creates them is deleted.
I am fairly new to Android, but I think your goal can be accomplished by using two Managers together.
First, you use the AccountManager to perform the necessary association of credentials and network resources.
Second, you use the BackupManager to save your application specific AccountManager records to the cloud. If your app is ever deleted, by virtue of Google Market tracking your app should be restored to the device, and through your app's implementation of BackupManager all the prior AccountManager records as well.
精彩评论