Kyle Banks

Creating a URI for an Android Resource

Written by @kylewbanks on Mar 15, 2013.

When using resources in an Android application, it is usually sufficient to make use the of resource manager with functions such as getString() and getDrawable(). Occasionally however, you will need to get the actual URI of a resource.

The process is very easy, as the URI has a very sensible setup:


All you need to do is replace the package name with your app's package name, as defined in the manifest, and the resource ID of the resource you would like to use.

Uri resourceURI = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.my_resource);
Let me know if this post was helpful on Twitter @kylewbanks or down below!