Problems with Android writing out and reading files

Android obtains the file directory through getRootDirectory and other methods, and then writes out the file. The corresponding file cannot be found locally, and the file path obtained by the same method cannot be read. Only getExternalCacheDir can find the corresponding file locally, but still can not read it. GetFilesDir can read normally but can not find the file locally

related codes

/ / Please paste the code text below (do not replace the code with pictures)

        //
        permission.requestPer(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, 1, new LllPermission.LllPermissionInter() {
            @Override
            public void execute() {

                ///storage/emulated/0/Android/data/io.github.grooters.lllerdemo/cache/lllerDemo_img.jpg
//        imgFile=new File(getActivity().getExternalCacheDir(),PHOTO_FILE_NAME);

                ///storage/emulated/0/lllerDemo_img.jpg
//        imgFile=new File(Environment.getExternalStorageDirectory(),PHOTO_FILE_NAME);

                ///data/user/0/io.github.grooters.lllerdemo/files/lllerDemo_img.jpg
        imgFile=new File(getActivity().getFilesDir(),PHOTO_FILE_NAME);

                ///data/lllerDemo_img.jpg
//        imgFile=new File(Environment.getDataDirectory(),PHOTO_FILE_NAME);

                ///system/lllerDemo_img.jpg
//                imgFile=new File(Environment.getRootDirectory(),PHOTO_FILE_NAME);

                Log.i(TAG,imgFile.getAbsolutePath());
                try {
                    if(imgFile.exists()){
                        imgFile.delete();
                    }
                    imgFile.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if(Build.VERSION.SDK_INT>=24){  //7.0Uri.fromFile()Uri
                    photoUri= FileProvider.getUriForFile(getActivity(),"io.github.grooters.lllerdemo.fileprovider",imgFile);
                }else{
                    photoUri=Uri.fromFile(imgFile);
                }
            }
        });

error type

java.lang.IllegalArgumentException: Failed to find configured root that contains

May.24,2021
Menu