java - Using external image as drawable resource -


so have image saved on external sd-card. now, want use image resource in project. (i want use image located @ specific path instead of r.drawable.image).

it great, if there way kinda "add" image resources (and not use it), image gets resourceid ones in r.drawable got.

but want display external image in imageview.

first need read external storage permission

<uses-permission android:name="android.permission.read_external_storage" /> 

then,

string imagepath = environment.getexternalstoragedirectory().getabsolutepath() +"directoryname/imagename.png";     bitmap bitmap = bitmapfactory.decodefile(imagepath);     imageview imageview = (imageview)findviewbyid(r.id.imageview);     imageview.setimagebitmap(bitmap); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -