问题描述
出于某种奇怪的原因,不断遇到不同类型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.
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:open failed:EACCES(Permission denied)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!