문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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 ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top