如何读取内存中存储的图像文件? [英] How to read image file stored in internal memory?

查看:111
本文介绍了如何读取内存中存储的图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我的内部存储器使用下面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>调用。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆