How to check if there is a newly created folder on the SD card in Android

From my application, I want to save some images to my SD card. To do this, I need to create one folder.

A folder is created for the first time, but after that it checks if this folder exists or not. How can i do this?

+8
android sd-card
source share
2 answers

below code will create directory if it doesn't exist

File direct = new File(Environment.getExternalStorageDirectory() + "/New Folder"); if(!direct.exists()) { if(direct.mkdir()) { //directory is created; } } 
+29
source share

You must first request the following permission in the Android manifest:

 android.permission.WRITE_EXTERNAL_STORAGE 

and execute the Razel code on it to work on it.

+8
source share

All Articles