Created
March 28, 2011 13:30
-
-
Save mstefanko/890453 to your computer and use it in GitHub Desktop.
retrieving phone numbers
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
//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