1

I have some images from drawable in an int array and now i want to convert each image from int array into URI. Can anybody tell me how can i do this. Thanks in advance. Here is my array

 int mBitmapIds = new int[]{ R.drawable.a, R.drawable.b,
                        R.drawable.c, R.drawable.d };

3 Answers 3

3
Uri[] uris = new Uri[mBitmapIds.lenght];
for (int i = 0; i < mBitmapIds.lenght; i++) {
  uris[i] = Uri.parse("android.resource://your.package.here/drawable/"+mBitmpaIds[i[);

}
Sign up to request clarification or add additional context in comments.

Comments

1

Something like:

int mBitmapIds = new int[]{ R.drawable.a, R.drawable.b,
                        R.drawable.c, R.drawable.d };
Uri[] uris = new Uri[4]:

for(int i=0; i<4; i++){
    uris[i] = Uri.parse("android.resource://your.package.name/" + mBitmapIds[i]);
}

Comments

0
String PACKAGE="com.yourpackage";    

URI getResourceUri(int resId) {
    return Uri.parse("android.resource://"+PACKAGE+"/" + resId);
}


URI[] getUris(int[] resIds) {
    URI[] uris=new URI[resIds.length];
    for (int i=0, len=resIds.length; i<len; i++) uris[i]=getResourceUri(resIds[i]);
    return uris;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.