How to determine the default phone number for a contact (if installed)

ATM I get the number and label of this identifier CONTACT_ID with

String where =  ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = " + contactId;
Cursor c = ctx.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, where, null, null);
     while (c.moveToNext()) {
     String number = Tools.getString(c, CommonDataKinds.Phone.NUMBER);
     String label = Tools.getString(c,CommonDataKinds.Phone.LABEL);
     }

Android has the ability to mark a given number as the "default number." How do I know if the requested number is the default number?

+5
source share
1 answer

Try executing the query for the IS_SUPER_PRIMARY column in the CONTENT_URI query.

If it returns a nonzero value, the entry can be interpreted as the default value of the contact of its kind (for example, the default phone number to use for the contact).

: http://developer.android.com/reference/android/provider/ContactsContract.Data.html

+7

All Articles