开发者

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

开发者 https://www.devze.com 2023-03-24 07:21 出处:网络
From my application, I want to store some images into my SD card. For that I need to create a one folder.

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 f开发者_开发百科older will create but after it checks whether that folder is present or not. How can I do it?


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

    }


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

精彩评论

暂无评论...
验证码 换一张
取 消