Here's a snippet of code I use for this task:

Resources resources = context.getResources();
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
resources.getResourcePackageName(resId) + '/' +
resources.getResourceTypeName(resId) + '/' +
resources.getResourceEntryName(resId) );

Tom.

On 3 October 2010 12:59, Neilz <neilhorn...@gmail.com> wrote:

> Hi. I'm sure this is simple, but I've got myself confused over it...
>
> I have an image resource, such as R.drawable.myimage, and I want to
> convert this into a URI.
>
> I tried:
>
> Uri selectedImage = Uri.parse("android.resource://com.my.package/" +
> resourceId);
>
> ...but this just returns a NullPointer. The resourceId needs to be
> dynamic (so I can pass any image to it), not just a hardcoded
> "myImage".
>
>
> Any help please?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to