Android解决getExternalStorageDirectory在29后废弃问题
Android解决getExternalStorageDirectory在29后废弃问题
File externalFileRootDir = context.getExternalFilesDir(null); do { externalFileRootDir = Objects.requireNonNull(externalFileRootDir).getParentFile(); } while (Objects.requireNonNull(externalFileRootDir).getAbsolutePath().contains("/Android")); String saveDir = Objects.requireNonNull(externalFileRootDir).getAbsolutePath(); mTempPhotoPathclone = saveDir + "/" + Environment.DIRECTORY_DCIM + "/" + System.currentTimeMillis()+".png";
//全部外部可用存储,通常作为媒体对用户不可见 返回Array<File>,null可以改为DIRECTORY_DCIM,DIRECTORY_DOCUMENTS,DIRECTORY_DOWNLOADS,DIRECTORY_PICTURES等 context.getExternalFilesDirs(null) //少了个s 懂得都懂 当然是第一个File context.getExternalFilesDir(null) //应用程序文件存储 context.getFilesDir()
此图转载至https://blog.csdn.net/gc1074959890/article/details/111691682