Tang Yuen Seng
Tang Yuen Seng

Reputation: 1

how to create folder and file in storage directory in android

I wanted to create some folders and some files to /storage/MyFolder/. I had tried to work on using /storage/emulated/0/MyFolder and it is working but i want to make hide under the storage root folder.

Is there any possible way for me to do this?

Upvotes: 0

Views: 8334

Answers (2)

Rishav Singla
Rishav Singla

Reputation: 483

You can create folder like this in External Storage directory:

String folder_main = "NewFolder";

File f = new File(Environment.getExternalStorageDirectory(), folder_main);
if (!f.exists()) {
f.mkdirs();
}

Upvotes: 1

Kishan Viramgama
Kishan Viramgama

Reputation: 1256

//get path to external storage (SD card)
String iconsStoragePath = Environment.getExternalStorageDirectory() + "/Abc/";
File sdIconStorageDir = new File(iconsStoragePath);

//create storage directories, if they don't exist

if(!sdIconStorageDir.exists()){
   sdIconStorageDir.mkdirs();
}

Upvotes: 0

Related Questions