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?
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.
AccountManager.renameAccount(Account account, String newName, AccountManagerCallback<Account> callback, Handler handler)
This has been unfortunately added only in API 21 (documentation). In previous versions, deleting and recreating the account with the new username is the only way, as mentioned in another answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With