Android的/数据/数据​​/ mypackage的/ IMG [英] Android /data/data/mypackage/img

查看:131
本文介绍了Android的/数据/数据​​/ mypackage的/ IMG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已保存相同的图像到/数据/数据​​/ mypackage中/ IMG /现在我想这显示全屏,我曾与ACTION_VIEW作秀与Android标准程序尝试,但它不是从/数据/数据​​读取/ ..
我该怎么办?

I have saved same image into /data/data/mypackage/img/ and now I want show this full screen, I had try with ACTION_VIEW for show with android standard program but it not read from /data/data/.. How can I do ?

推荐答案

在'Android的标准程序您正在启动是不能访问/数据/数据​​/ mypackage中,因而无法加载你有保存图像

The 'android standard program' you are launching is not able to access /data/data/mypackage, and thus cannot load the images you are saving in there

尝试在SD卡上的目录中保存的图像,而不是:

Try saving your images in a directory on the SD card instead:

File sdDir = new File(Enviroment.getExternalStorageDirectory(), "mydirname");

如果您的设备没有SD卡,那么你需要创建你的包里面目录世界可读的子目录,然后在其中创建一个世界可读的文件(安卓2.3 +)

If your device doesn't have an SD card then you will need to create a world readable subdirectory inside your package dir, and then create a world readable file within it (Android 2.3+)

File filesysDir = getDir("mydirname", MODE_WORLD_READABLE);
File file = new File(sdDir, "myfile.txt");
file.setReadable(true, false);
FileOutputStream fos = new FileOutputStream(file);
String txt = "hello world";
fos.write(txt.getBytes());
fos.close();

或者如果你是在早期版本的Andr​​oid看起来你没有在目录名中得到太多的选择。下面code将在数据/数据​​/ mypackagename /文件/目录下建立一个世界可读的文件

Or if you are on earlier versions of Android it looks like you don't get much choice in the directory name. The following code will create a world readable file in the data/data/mypackagename/files/ directory

FileOutputStream fos = openFileOutput("myfile2.txt", MODE_WORLD_READABLE);
String txt = "hello world";
fos.write(txt.getBytes());
fos.close();

这篇关于Android的/数据/数据​​/ mypackage的/ IMG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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