That's how I change the ringtone:
RingtoneManager.setActualDefaultRingtoneUri(context, type, ringtoneUri)
How can I check if the ringtone is changed with my sound file?
private static void setActualRingtone(@NonNull Context context, @NonNull Uri ringtoneUri, int type) {
RingtoneManager.setActualDefaultRingtoneUri(context, type, ringtoneUri);
if(RingtoneManager.isDefault(ringtoneUri)){
Toast.makeText(context, "Operation successful=)", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, "Operation failed=)", Toast.LENGTH_SHORT).show();
}
}
You can check it with the following function:
For more information please refer the documentation.