Get URI of .mp3 file stored in res/raw folder in android

Finally after searching a lot i found the solution.

If you want to get any resource URI then there are two ways :

  1. Using Resource Name

    Syntax : android.resource://[package]/[res type]/[res name]

    Example : Uri.parse("android.resource://com.my.package/drawable/icon");

  2. Using Resource Id

    Syntax : android.resource://[package]/[resource_id]

    Example : Uri.parse("android.resource://com.my.package/" + R.drawable.icon);

This were the examples to get the URI of any image file stored in drawable folder.

Similarly you can get URIs of res/raw folder.

In my case i used 1st way ie. Using Resource Name

Leave a Comment