拍的照片无法存储到外部存储的共有文件夹中,怎么办?
下面代码,无法将拍的照片存储到共有文件夹中,编译时提示“Result of 'File.createNewFile()' is ignored,运行时提示“permission denied”,请问如何解决?
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/ADC/";
File file = new File(path + picName + "_0.jpg");
try {
if (!Objects.requireNonNull(file.getParentFile()).exists()){
file.getParentFile().mkdir();
}
if (!file.exists()){
file.createNewFile();
}
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
croppedBmp_0.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
正在回答
1)SD卡的读写权限加了没有? 2)请继续学习3-5动态权限的申请。祝:学习愉快
- 参与学习 人
- 提交作业 220 份
- 解答问题 1800 个
本阶段是联网及数据处理的必备技能。课程从网络基础知识到线程间协同工作、异步下载处理;从文件存储、到轻量级数据库SQLite的使用;最后利用最流程的第三方框架助你快速开发企业级APP。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星