Skip to content

Instantly share code, notes, and snippets.

@codesburner
Forked from mstefanko/gist:890450
Created April 5, 2011 08:20
Show Gist options
  • Select an option

  • Save codesburner/903231 to your computer and use it in GitHub Desktop.

Select an option

Save codesburner/903231 to your computer and use it in GitHub Desktop.
//Basic contact information stored in Contacts table with detailed information stored in individual //tables for normalization. In Android 2.0 to query the base contact records the URI to query is stored //in ContactsContract.Contacts.CONTENT_URI.
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(
cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(
cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
//TODO:Query phone here.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment