如何读取内存中存储的图像文件? [英] How to read image file stored in internal memory?
本文介绍了如何读取内存中存储的图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android应用程序,我的内部存储器使用下面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();
任何一个可以请帮我读从内部显示它这个图像文件中的activty?
Can any one please help me to read this image file from internal display it in an activty?
推荐答案
试试这个:
ImageView imageView = (ImageView) findViewById(R.id.image);
File filePath = getFileStreamPath(fileName);
imageView.setImageDrawable(Drawable.createFromPath(filePath.toString()));
在上面的代码 R.id.image
是的ImageView
地方在你的布局ID。 文件名
是在 openFileOutput $ C $使用的文件的
字符串
包含名称C>调用。
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.
这篇关于如何读取内存中存储的图像文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文