Created
March 28, 2011 13:31
-
-
Save mstefanko/890454 to your computer and use it in GitHub Desktop.
retrieving email addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Querying email addresses is similar to phone numbers. A query must be performed to get email addresses //from the database. Query the URI stored in ContactsContract.CommonDataKinds.Email.CONTENT_URI to query the //email address table. | |
Cursor emailCur = cr.query( | |
ContactsContract.CommonDataKinds.Email.CONTENT_URI, | |
null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", | |
new String[]{id}, null); | |
while (emailCur.moveToNext()) { | |
// This would allow you get several email addresses | |
// if the email addresses were stored in an array | |
String email = emailCur.getString( | |
emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)); | |
//TODO : Do something with email | |
String emailType = emailCur.getString( | |
emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE)); | |
} | |
emailCur.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment