【发布时间】:2014-12-30 15:56:08
【问题描述】:
我正在尝试根据here 的说明将图像写入文件。但是,我得到了这个例外:
libcore.io.ErrnoException: open failed: EACCES (Permission denied)
这是我的代码,显然会弹出此异常:
private File createImageFile(int side) throws IOException {
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "";
if (side==1) {
imageFileName = "Front_"+timestamp;
} else {
imageFileName = "Side_"+timestamp;
}
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName,
".jpg",
storageDir
);
// Save the file
mCurrentPhotoPath = "file:"+image.getAbsolutePath();
return image;
}
提前感谢您的帮助。
【问题讨论】: