How to detect the default phone number of a contac

2019-02-23 00:38发布

ATM I get the number and label of a given 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 "default number". How can I find out if the queried number is the default number?

1条回答
贼婆χ
2楼-- · 2019-02-23 00:54

Try to query for the column IS_SUPER_PRIMARY in your CONTENT_URI query.

If it returns a non-zero value then the entry may be interpreted as the default contact value of its kind (for example, the default phone number to use for the contact).

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

查看更多
登录 后发表回答