Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read image file stored in internal memory?

Tags:

android

image

In my android application I an storing an image file in internal memory using below code-

FileOutputStream fos = con.openFileOutput(fileName, con.MODE_PRIVATE);
fos.write(baf.toByteArray()); // baf - ByteArrayBuffer
fos.close();

Can any one please help me to read this image file from internal display it in an activty?

like image 673
dwarkesh Avatar asked Sep 27 '10 09:09

dwarkesh


1 Answers

Try this:

ImageView imageView = (ImageView) findViewById(R.id.image);
File filePath = getFileStreamPath(fileName);
imageView.setImageDrawable(Drawable.createFromPath(filePath.toString()));

In the above snippet R.id.image is id of ImageView somewhere in your layout. fileName is a String containing name of the file you used in openFileOutput call.

like image 100
Konstantin Burov Avatar answered Oct 05 '22 02:10

Konstantin Burov