I'm trying to set ringtone to specific contact for android 10 but it's not working. I'm getting mp3 file uri and specific contact uri using contact id and passing both to content resolver update function. i've tried many methods both nothing is working. Following is my code.
val contactUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contactId)
val values = ContentValues()
val fileUriRingtone = FileProvider
.getUriForFile(this, BuildConfig.APPLICATION_ID, file)
.toString()
values.put(
ContactsContract.Contacts.CUSTOM_RINGTONE, fileUriRingtone
)
val result = contentResolver.update(contactUri, values, null, null)