打开失败:ENOENT(没有这样的文件或目录(
已经添加了清单,因为Environment.getExternalStorageDirectory((在Android R上不推荐使用。如果我将其更改为getExternalFilesDir((,则路径将指向应用程序目录,而不是存储
android:requestLegacyExternalStorage="true"
安卓Q下面工作正常,但安卓R得到ENOENT错误
protected Uri getImageFile()
{
String imagePathStr = IMAGE_FOLDER;
File path = new File(imagePathStr);
if (!path.exists()) {
path.mkdirs();
}
String finalPhotoName = "IMG" +
(withTimeStamp ? "_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date(System.currentTimeMillis())) : "")
+ ".png";
// long currentTimeMillis = System.currentTimeMillis();
// String photoName = imageName + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date(currentTimeMillis)) + ".jpg";
File photo = new File(path, finalPhotoName);
return Uri.fromFile(photo);
}
IMAGE_FOLDER 的字符串是什么
尝试使用
getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)