I would like to add a custom ringtone in a rawcontact (before create the contact).
I used this code with succes to add a custom ringtone in a contact (already created):
String select = ContactsContract.Contacts._ID + "=?";
String[] args = new String[]{getAndroidId()};
changesToCommit.add(ContentProviderOperation.newUpdate(ContactsContract.Contacts.CONTENT_URI)
.withSelection(select, args)
.withValue(ContactsContract.Contacts.CUSTOM_RINGTONE, ringtone_uri_string)
.build());
So now, i try to insert a custom ringtone in a rawcontact (a new contact not already created). I've tried with this code:
changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
.withValueBackReference(ContactsContract.RawContacts._ID, 0)
.withValue(ContactsContract.RawContacts.CUSTOM_RINGTONE, ringtone_uri_string)
.build());
But it doesn't work. Any ideas ?
CUSTOM_RINGTONE
is aContacts
table field, notRawContacts
.You'd need to reference a contact-id, not a raw-contact-id, so I'm not sure that's possible while inserting a new raw contact.
EDIT
You're right, seems like I've missed that other
CUSTOM_RINGTONE
field inRawContacts
. In that case, I think this should be a part of the first call to add the raw-contact, something like this: