I need to retrieve all the email addresses of the user, stored in the device (not the email addresses of his friends, but his OWN email addresses). For example, if I've three mail addresses geltrude@gmail.com, geltry@yahoo.co.uk and cippalippa@hotmail.com, i'm looking for a method that returns an array (or similar) with these three Strings: ["geltrude@gmail.com", "geltry@yahoo.co.uk", "cippalippa@hotmail.com"]. Any idea?
Edit: I'd like to get the email addresses stored in the "me" contact on the device, plus the own email addresses stored in the default mail app and in the gmail client app (that are the default used apps, I think). Thanks in advance. G.
Most of those addresses are maintained by email clients which don't have content providers to get at them.
If your goal is to use the address list to select the return address for an outgoing email, that doesn't fit the Android way of doing things. Your application should announce that it wants to send an email by throwing out a properly-outfitted
ACTION_SEND
intent. Whatever application ultimately services it may give the user a choice about which account and return address to use in sending it.Addendum:
The default email client has a content provider called
content://com.android.email.provider/account
that you shouldn't or can't use because:com.android.email.permission.ACCESS_PROVIDER
permission.protectionLevel
ofsignatureOrSystem
, which restricts grants to apps stored in the system image or signed with the same key as those in the system image. Your application is unlikely to fall into either of those categories.Other things to be aware of: