Android 10以上获取存储路径的方式

getApplicationContext().getFilesDir().getAbsolutePath() + "/" + "save"
Environment.DIRECTORY_PICTURES + "/" + "save"
File myCaptureFile = null;
try {
    // 已挂载
    File pic = ctx.getExternalFilesDir(Environment.DIRECTORY_PICTURES + "/save");
    if (!pic.exists()) {
        pic.mkdirs();
    }
    myCaptureFile = File.createTempFile("utc", ".jpg", pic);
    if (!myCaptureFile.exists()) {
        myCaptureFile.createNewFile();
    }
    mCurrentPhotoPath = myCaptureFile.getAbsolutePath();
    Log.i(TAG, "=====camera path:" + mCurrentPhotoPath);
} catch (IOException e) {
    e.printStackTrace();
}
    原文作者:阿聪不秃头
    原文地址: https://blog.csdn.net/congcongguniang/article/details/123105604
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞