Phone numbers
Phone numbers are stored in their own table and must be requested separately. To query the phone number table, use the URI stored in the ContactsKontract.CommonDataKinds.Phone.CONTENT_URI SDK variable. Use WHERE 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()) {
Run the second query to the SQLite database for Android contacts. Phone numbers are requested against the URIs stored in ContactsContract.CommonDataKinds.Phone.CONTENT_URI. The contact ID is stored in the phone table as ContactsContract.CommonDataKinds.Phone.CONTACT_ID, and the WHERE clause is used to limit the data returned.
Email Addresses
Requesting email addresses is similar to phone numbers. To obtain email addresses from the database, you must complete the request. Request the URI stored in ContactsContract.CommonDataKinds.Email.CONTENT_URI to request an 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()) {
source share