Question

How to set a contact's phone number to be primary number when adding or updating a contact building a custom contacts provider. The adding and updating of contacts is working fine but I don't know how to set one number of the contact to be primary, or default number.

Was it helpful?

Solution

mValues.put(Phone.IS_PRIMARY, 1);
mValues.put(Phone.IS_SUPER_PRIMARY, 1);

Both Phone.IS_PRIMARY and Phone.IS_SUPER_PRIMARY have to be set.

OTHER TIPS

I had the same problem, my solution is:

ContentProviderOperation.Builder bld = ContentProviderOperation.newUpdate(Uri.withAppendedPath(ContactsContract.Data.CONTENT_URI, myRawIdOfNumber ));
bld = bld.withValue( ContactsContract.CommonDataKinds.Phone.IS_PRIMARY, new Integer(1) );
bld = bld.withValue( ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY, new Integer(1) );
ops.add( bld.build() );
try { getContentResolver().applyBatch( ContactsContract.AUTHORITY, ops ); } catch ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top