How to create a directory in Android?

前端 未结 4 1005
礼貌的吻别
礼貌的吻别 2021-01-13 05:16

Everything is in the question. Here is my code :

    private void createDirectory(File currentDirectory) {
  File f = null;
  try {

   f = new File(current         


        
4条回答
  •  庸人自扰
    2021-01-13 05:41

    First, please use the File constructor that takes a File for your directory and a String for your desired subdirectory.

    Beyond that, most likely you are attempting to create a directory where you are not allowed, either because:

    • currentDirectory does not exist, or
    • currentDirectory points to a place on the on-board flash storage where you are not allowed to write, or
    • currentDirectory points to a place on the external storage and you lack the WRITE_EXTERNAL_STORAGE permission

提交回复
热议问题