Java tutorial
//package com.java2s; //License from project: Apache License import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; public class Main { /** * Get account by type and name * @param context context * @param accountType account type * @param accountName account name * @return Account object */ public static Account getAccount(Context context, String accountType, String accountName) { final AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccountsByType(accountType); if (accounts == null || accounts.length == 0) { return null; } else { for (Account account : accounts) { if (account.name.equals(accountName)) { return account; } } return null; } } }