So I am working with URIs in Android to set ringtones for individual contacts. Problem is, the way the ringtone selector works is that it doesn't like something such as myringtone.mp3
. Instead, it just wants myringtone
. Weird, but I guess that's just how it goes. So I have a URI like file:///sdcard/tag/ringtones/ringtone.mp3
. How would I get the URI to remove the extension so the ringtone manager uses it properly? The way ringtones are set are with this line:
values.put(ContactsContract.Contacts.CUSTOM_RINGTONE, uri.toString());
So the URI is in string form. Using substrings I should be able to do it, but I don't know how I'd write a method to remove the final 4 characters in a string. Can anyone give me some advice here?
Thanks!
Have you tried?...
uri.toString().substring(0, uri.toString().length() - 4);