4

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.

3
  • @Rishabh: I just want to delete the ringtone, that I inserted first. I hope that can be done somehow. Dec 20, 2012 at 11:10
  • So you can go the directory & search with name that you previously inserted & after that remove it. Dec 20, 2012 at 11:15
  • @MoshErsan: Yes, even I want to do that, but I need some really helpful solutions for that. Dec 20, 2012 at 14:10

1 Answer 1

6

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
}
8
  • What path should I provide to getContentUriForPath(), I only have the music path of sdcard, from where I am getting it to set as ringtone, and other than that, I am having ringtone title. Thats all, what I do have. Dec 20, 2012 at 11:31
  • @NarendraDroidWorm : exactly just pass sdcard file path Dec 20, 2012 at 11:38
  • I did the same as you suggested, but it actually deleted the original file, which I don't want. I just want that to be removed from ringtone list. Dec 20, 2012 at 12:12
  • @Prosper: yes, I checked it, it deleted the original fiie, which I don't want. Dec 20, 2012 at 12:20
  • I just want to remove it from the system ringtone list. How can I achieve that? Dec 20, 2012 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.