Search code examples
androidaudiouriringtoneandroid-contentresolver

Get content:// Uri of Current Ringtone


I am trying to get the content uri (content://media/external/...) of the current ringtone.

I get the current device ringtone like this:

Uri uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE);`

However, calling uri.getPath() returns external/audio/media/50. It is missing content://media/ in front of it. I have thought about manually pasting it to the beginning but that just seems wrong.

How do I properly get the content:// uri of the current ringtone?

Thank you!


Solution

  • Use uri.toString() instead of uri.getPath().

    uri.getPath() is usually used by ContentProvider when it wants to decode the uri and create query.