How to check if newly created folder is present in

2019-01-23 07:59发布

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 whether that folder is present or not. How can I do it?

2条回答
对你真心纯属浪费
2楼-- · 2019-01-23 08:15

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;
          }

    }
查看更多
姐就是有狂的资本
3楼-- · 2019-01-23 08:38

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.

登录 后发表回答