Code example for AccountManager

Methods: addAccountExplicitlygetAccountsByType

            try { 
                Log.d(TAG, "SigninTask:doInBackground()");
                // Check to see if there is an account already 
                mAccountManager = AccountManager.get(AccountSignin.this);
                Account accounts[] = mAccountManager.getAccountsByType(ACCOUNT_TYPE);
                if (accounts.length == 0) {
                    // Create a new Account 
                    Account account = new Account(mUsername, ACCOUNT_TYPE);
                    mAccountManager.addAccountExplicitly(account, mPassword, null);
                } else { 
                    // Do whatever needs to be done if an account already exists... like update a password 
            } catch (Exception e) {
Experience pair programming with AI  Get Codota for Java