Created
March 28, 2011 13:30
-
-
Save mstefanko/890450 to your computer and use it in GitHub Desktop.
Retrieving contact details
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
//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