开发者

Howto let a user change account data in 'Accounts and sync'

开发者 https://www.devze.com 2023-03-16 19:51 出处:网络
There is an existing account on the phone that is used for a sync service. The account has some settings that the user entered when he created the account. Theses settings are stored as user data (-->

There is an existing account on the phone that is used for a sync service. The account has some settings that the user entered when he created the account. Theses settings are stored as user data (--> mAccountManager.addAccountExplicitly(account, mPassword, userData)).

The user should be able to change these settings. How can this be achieved? Do I need a standalone app to change existing account data?

I guess the user would go to 'Se开发者_StackOverflowttings'/'Accounts and sync'/'myAccount' and should find a menu entry like 'modify account data'. This menu entry should open the same activity that the user has already used to enter the data initially.

Any hints to push me in the right direction?


This fooled me for a while too - I expected to find getUserData()/setUserData() methods on the Account class, but they are on the AccountManager instead:

AccountManager am = AccountManager.get(context);
String myData = am.getUserData(account, SomeClass.MY_DATA_KEY);
myData = "Some New Value";
am.setUserData(account, SomeClass.MY_DATA_KEY, myData);

Check out the AccountManager setUserData method docs for more information.

Cheers, Andrew.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号