Skip to content

Instantly share code, notes, and snippets.

@mstefanko
Created March 28, 2011 13:30
Show Gist options
  • Save mstefanko/890453 to your computer and use it in GitHub Desktop.
Save mstefanko/890453 to your computer and use it in GitHub Desktop.
retrieving phone numbers
//retrieving phone numbers
//Phone numbers are stored in their own table and need to be queried separately. To query the phone //number table use the URI stored in the SDK variable ContactsContract.CommonDataKinds.Phone.CONTENT_URI. //Use a WHERE conditional to get the phone numbers for the specified contact.
if (Integer.parseInt(cur.getString(
cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Cursor pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
new String[]{id}, null);
while (pCur.moveToNext()) {
// TODO: Do something with phones
}
pCur.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment