In my code I'm setting a sound file as a ringtone. It mostly works fine.
This issue is that it doesn't use the ContentValue's TITLE entry for the Ringtone name in the ringtone list. In the following code, I set the TITLE key to "Custom Name". But in the ringtone selection list it insists on showing up as "testTone" (The filename is "testTone.mp3").
// Take the given file and add it to the ringtone list
private Uri makeRingtone(File soundFile) {
String path = soundFile.getAbsolutePath();
// Make sure the system knows about it
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse("file://"+path)));
// Plug in same important values
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, path);
values.put(MediaStore.MediaColumns.TITLE, "Custom Name");
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
values.put(MediaStore.Audio.Media.IS_ALARM, true);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
// The ol' delete then insert trick:
Uri uri = MediaStore.Audio.Media.getContentUriForPath(path);
getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + path + "\"", null);
Uri newUri = getContentResolver().insert(uri, values);
Log.d(TAG, "New Uri: " + newUri);
return newUri;
}
This is similar to the issue: Saving sounds as ringtones using the title of the sound instead of number location