Skip to content Skip to sidebar Skip to footer

How To Create A Folder In Download Directory (android Studio)

I'd like to create a directory in a Download directory (the one which stores all the files I download from web) so I can see it in browser after I plug the mobile into my PC. File

Solution 1:

Filedir=newFile(Environment.getExternalStorageDirectory() + "/Download/your folder/");
dir.mkdirs(); // creates needed dirs

Don't forget to ask for permissions on Marshmallow or newer and to add the write storage permission to Android Manifest, for example: https://stackoverflow.com/a/34722591/4479004

Solution 2:

try following code

privatevoidcreateDirectoryAndSaveFile() {

Filedirect=newFile(Environment.getExternalStorageDirectory() + "/Download/DirName");

if (!direct.exists()) {
    FilewallpaperDirectory=newFile("/sdcard/Download/DirName/");
    wallpaperDirectory.mkdirs();
 }
}

Post a Comment for "How To Create A Folder In Download Directory (android Studio)"