get All Accounts - Android Account

Android examples for Account:Account Information

Description

get All Accounts

Demo Code


//package com.java2s;
import android.accounts.Account;
import android.accounts.AccountManager;

import android.content.Context;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static List<Account> getAllAccounts(Context context) {
        List<Account> accounts = new ArrayList<Account>();
        if (context == null) {
            return accounts;
        }//from  ww w  .j a  v  a  2s .  c  om
        Account[] allAccounts = AccountManager.get(context).getAccounts();
        if (allAccounts == null) {
            return accounts;
        }
        return Arrays.asList(allAccounts);
    }
}

Related Tutorials