Example usage for android.accounts AccountManager setPassword

List of usage examples for android.accounts AccountManager setPassword

Introduction

In this page you can find the example usage for android.accounts AccountManager setPassword.

Prototype

public void setPassword(final Account account, final String password) 

Source Link

Document

Sets or forgets a saved password.

Usage

From source file:Main.java

/**
 * Sets password of account, creates a new account if necessary.
 *///w  w  w . j av  a 2 s . c o m
private static Account findOrCreateAccount(AccountManager accountManager, String username, String refreshToken,
        String accountType) {

    for (Account account : accountManager.getAccountsByType(accountType)) {
        if (account.name.equals(username)) {
            accountManager.setPassword(account, refreshToken);
            return account;
        }
    }

    Account account = new Account(username, accountType);
    accountManager.addAccountExplicitly(account, refreshToken, null);
    return account;
}