0

I know how to open gallery intent and to display in the imageview.

But I am facing problem in selecting image automatically in oncreate method and display in the imageview.

I have an image in gallery folder with name "myfile.jpg"

Can anyone guide me how to do it without openting gallery intent.

Thank you in advance

V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
Fay Lass
  • 15
  • 2

1 Answers1

1

Here is solution :

ImageView image = (ImageView)findViewById(R.id.myImage);

File root = Environment.getExternalStorageDirectory();
String path = root.getAbsolutePath();
path = path + File.separator + "myfile.jpg"; //where you image file located

Bitmap myBitmap = BitmapFactory.decodeFile(path);

image.setImageBitmap(myBitmap);
Deepak Kumar
  • 1,035
  • 10
  • 18