Removing software ringtone in android

I know that inserting a ringtone is programmatic, but I want to know about removing a specific ringtone from the list of ringtones of the system. I know this is the name of the ringtone.

I talked a lot about this, but, unfortunately, I could not find a way to achieve exactly what I want.

Please tell me how to delete a ringtone using the name of the ringtone.

+4
source share
1 answer

Try to remove the ringtone from MediaStore.Audio.Media

 Uri uri = MediaStore.Audio.Media.getContentUriForPath(ringtone_path); int roweffected = getContentResolver().delete(uri, MediaStore.MediaColumns.DATA + "=\"" + ringtone_path + "\"", null); if(roweffected>0){ //ringtone deleted } else{ //ringtone not deleted } 

EDIT: you can also remove RINGTONE from the list as:

 ContentValues cv = new ContentValues(); Uri uri = MediaStore.Audio.Media.getContentUriForPath(ringtone_path); cv.put(MediaStore.Audio.Media.IS_RINGTONE, false); cv.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); cv.put(MediaStore.Audio.Media.IS_ALARM, false); cv.put(MediaStore.Audio.Media.IS_MUSIC, true); int rowupdate = getContentResolver().update(uri, cv, MediaStore.MediaColumns.DATA + "=?",new String[] {ringtone_path}); if(rowupdate>0){ //ringtone update } else{ //ringtone not update } 
+5
source

All Articles