2 qq 35071078 qq_35071078 于 2017.01.05 11:29 提问

ANDROID 读取系统图片失败

我是先获取了系统图库里的某个图片的路径 path,然后
File file = new File(path);
InputStream is = new FileInputStream(file);
然后就报错W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Tencent/QQ_Images/null-52a51a941f2792db.jpg: open failed: EACCES (Permission denied)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:459)
W/System.err: at java.io.FileInputStream.(FileInputStream.java:76)
W/System.err: at com.fc.net.UploadUtil.uploadFile(UploadUtil.java:72)
W/System.err: at com.fc.ui.activity.club.CreateClubActivity$3.run(CreateClubActivity.java:149)
W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
W/System.err: at libcore.io.Posix.open(Native Method)
W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:445)
W/System.err: ... 3 more

3个回答

stone_you
stone_you   2017.01.05 13:48
已采纳

你的tagetsdk大于等于23吗?如果是的话,需要动态申请权限,在manifest里申请是不行的

qq626215761
qq626215761   2017.01.05 11:36

没有申请文件读写权限

qq_35071078
qq_35071078 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>加了权限的
11 个月之前 回复
yinwending
yinwending   2017.01.12 17:17

代码动态申请读写权限

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!