How to check if newly created folder is present into SD Card in Android

前端 未结 2 2062
臣服心动
臣服心动 2020-12-15 12:04

From my application, I want to store some images into my SD card. For that I need to create a one folder.

At the first time folder will create but after it checks w

相关标签:
2条回答
  • 2020-12-15 12:40

    below code will create a directory if it does not exist

       File direct = new File(Environment.getExternalStorageDirectory() + "/New Folder");
    
       if(!direct.exists())
        {
            if(direct.mkdir()) 
              {
               //directory is created;
              }
    
        }
    
    0 讨论(0)
  • 2020-12-15 12:42

    You should request the following permission first in your Android manifest :

    android.permission.WRITE_EXTERNAL_STORAGE
    

    and execute above code by Rasel for it to work.

    0 讨论(0)
提交回复
热议问题