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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -