Skip to content

Instantly share code, notes, and snippets.

@codesburner
Forked from mstefanko/gist:890454
Created April 5, 2011 08:20
Show Gist options
  • Save codesburner/903229 to your computer and use it in GitHub Desktop.
Save codesburner/903229 to your computer and use it in GitHub Desktop.
//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