Skip to content Skip to sidebar Skip to footer

Create Directory In External Storage In Android

Hello I am trying to create a directory in the external storage but it is not working for me. I debugged the application there I find that code execute perfectly myDirectory.mkdirs

Solution 1:

Try this:

booleansuccess= (newFile(getActivity().getApplicationContext().getFilesDir()+"/YourAppFolderName")).mkdir(); 
        if (!success){
            Log.w("directory not created", "directory not created");
        }

Also in the manifest:

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Solution 2:

Yeah really very silly mistake I made, forgot to add permission to write in the SD Card but it should have thrown the exception

Anyway, it solved my issue

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Post a Comment for "Create Directory In External Storage In Android"