Java tutorial
//package com.java2s; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; public class Main { /** * Get URI string from resourceId. * * @param context The context. * @param resourceId The resource id. * @return The URI string. */ public static String getUriString(final Context context, final int resourceId) { if (context == null) { throw new IllegalArgumentException("context == null"); } return new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE).authority(context.getPackageName()) .appendPath(Integer.toString(resourceId)).toString(); } }