mkdir() works while inside internal flash storage, but not SD card?

前端 未结 4 621
慢半拍i
慢半拍i 2020-11-29 04:33

I am currently building a file management app that allows the user to browse the file system of their device. The user starts off in the root directory / of the

4条回答
  •  误落风尘
    2020-11-29 04:57

    path.mkdir() fails also when the directory already exists. You can add a check first:

    if (!path.exists()) {
       boolean success = path.mkdir();
       Log.d(TAG, path.getAbsolutePath() + FOLDER_CREATION_SUCCESS + success);
       path.delete();
    } else {
       Log.d(TAG, path.getAbsolutePath() + "already exists");
    }
    

提交回复
热议问题