Code to fetch account details in Android

05 Sep

We can fetch account name using:;
and the encrypted password using:

one more way:
public String getUsername()
AccountManager manager = AccountManager.get(this);
Account[] accounts = manager.getAccountsByType(“”);
List<String> possibleEmails = new LinkedList<String>();

for (Account account : accounts) {
// TODO: Check possibleEmail against an email regex or treat
// as an email address only for certain account.type values.

if(!possibleEmails.isEmpty() && possibleEmails.get(0) != null){
String email = possibleEmails.get(0);
String[] parts = email.split(“@”);
if(parts.length > 0 && parts[0] != null)
return parts[0];
return null;
return null;

Leave a comment

Posted by on September 5, 2011 in Android Source Code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: