开发者

How to read image file stored in internal memory?

开发者 https://www.devze.com 2023-01-17 13:28 出处:网络
In my android application I an storing an image file in internal memory using below code-开发者_如何学编程

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消