Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 925
nikmin Avatar asked Apr 26 '13 11:04

nikmin


2 Answers

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.

like image 109
nikmin Avatar answered Oct 26 '22 23:10

nikmin


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.

like image 22
fast3r Avatar answered Oct 26 '22 23:10

fast3r