且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何读取内存中存储的图像文件?

更新时间:2023-11-25 18:27:52

试试这个:

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.