Android异常:java.io.IOException:打开失败:EACCES(权限被拒绝) [英] Android Exception : java.io.IOException: open failed: EACCES (Permission denied)

查看:57
本文介绍了Android异常:java.io.IOException:打开失败:EACCES(权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种奇怪的原因,我经常面临不同类型的 Android 设备的问题,将捕获的图像保存在设备存储中.

For some strange reason, am constantly facing an issue with different types of Android devices, for saving the captured images on the device storage.

这里是详细的错误日志,实际上是什么.

Here, is the detailed error log, of what, actually am getting.

java.io.IOException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:940)
at com.parkhya.pick_for_shareAflash.HomeActivity.resizeImage(HomeActivity.java:456)
at com.parkhya.pick_for_shareAflash.HomeActivity.onActivityResult(HomeActivity.java:393)
Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
at java.io.File.createNewFile(File.java:933)

虽然,所有其他 Android 应用程序,如 Instagram 和其他应用程序,都能够将相机点击的图像保存在设备上.任何人,你能建议我应该怎么做,为了让我的应用程序将相机图片保存在 sdcard 中.

Although, all the other Android apps, like, Instagram and others, are able to save the camera clicked images on the devices. Anybody, can you please suggest, what should I do, in order for my app, to save the camera pictures in sdcard.

推荐答案

这可能对你有所帮助.在 sdcard 上写入文件时,我面临同样的问题.我已经设置了写入文件所需的所有权限,但我使用了如下文件对象:

This may help you. I face the same issue when writing the file on sdcard. I have set all required permission to write the file but I used the file object like below:

错误:

File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile()+fileName);

正确:

File myFile = new File(Environment.getExternalStorageDirectory().getAbsoluteFile(), fileName);

这意味着路径错误.

这篇关于Android异常:java.io.IOException:打开失败:EACCES(权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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