I know inserting a ringtone programmatically, but I want to know about deleting a specific ringtone from the system ringtone list. What I know, is the title of the ringtone.
I googled a lot about it, but unluckily, couldn't find any way to achieve exactly what I want.
Please, guide me the way to delete the ringtone using title of the ringtone.
Try as to delete an 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 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
}