Sebastian Schneider Sebastian Schneider - 11 months ago 51
Android Question

Android custom account retreive the password

I've created a custom account according to doc, i have a class extending

and the service.

I add an account like this:

public static void addCustomAccount(Context context, String title, String password) {
AccountManager accountManager = AccountManager.get(context);
Account account = new Account(title, Constants.ACCOUNT_KEY);
if (accountManager.addAccountExplicitly(account, password, null)) {
Log.v(Constants.LOGTAG, "Account in Android Accounts was created");

Everything works perfectly, the account is displayed in the settings.

My question is:

How can i retreive the password i've set in this procedure?

Answer Source

Seems like AccountManager#getPassword(Account account) is what you need.

And you can get your Account object via the getAccounts method of the manager as well

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download