📌  相关文章
📜  在 Android 11 站点上保存文档:stackoverflow.com - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:31.444000             🧑  作者: Mango

代码示例1
public  static  File commonDocumentDirPath(String FolderName){
        File dir = null ;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            dir = new File (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)+ "/"+FolderName );
        } else {
            dir = new File(Environment.getExternalStorageDirectory() + "/"+FolderName);
        }

    // Make sure the path directory exists.
   if (!dir.exists()) {
          // Make it, if it doesn't exit
         boolean success=dir.mkdirs();
         if(!success) {dir=null;}


   }
            
        return  dir ;

    }