打开失败:ENOENT Android R

open failed: ENOENT Android R

open failed: ENOENT (No such file or directory)

已添加清单,因为 Environment.getExternalStorageDirectory() 在 Android R.if 上已弃用 R.if 我将其更改为 getExternalFilesDir() 路径将转到应用程序目录,而不是存储

android:requestLegacyExternalStorage="true" 

Android Q 下面工作正常但是 Android 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)