androidaccountmanagerandroid-syncadapterandroid-account

Change username and password of android custom account


I have created sync adapter for android that syncs data with my server. I works fine, but now I want to be able to change my username and password without removing and adding the account again. How can I do this?

I have a login screen that has edit texts for entering username and password, but how to apply these changes to the account?

EDIT:

Found a way how to change the password:

AccountManager.get(mContext).setPassword(account, password );

where account is my account, and password is the new password.

So now my question is: HOW TO CHANGE THE USERNAME?


Solution

  • I can change the password with no problem, but if I want to change the username of the account I must delete and recreate the account with the new username. This deletes all data from that account and resyncs the account again from the beginning.