在我的 Android 应用程序中,我使用以下代码将图像文件存储在内部存储器中-
FileOutputStream fos = con.openFileOutput(fileName, con.MODE_PRIVATE);
fos.write(baf.toByteArray()); // baf - ByteArrayBuffer
fos.close();
任何人都可以帮我从内部读取此图像文件并将其显示在活动中吗?
尝试这个:
ImageView imageView = (ImageView) findViewById(R.id.image);
File filePath = getFileStreamPath(fileName);
imageView.setImageDrawable(Drawable.createFromPath(filePath.toString()));
在上面的片段中R.id.image
的 ID 是ImageView
在你的布局中的某个地方。fileName
is a String
包含您使用的文件的名称openFileOutput
call.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)