在我的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 调用。
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.