how to create a folder in android External Storage Directory?
Do it like this :
String folder_main = "NewFolder";
File f = new File(Environment.getExternalStorageDirectory(), folder_main);
if (!f.exists()) {
f.mkdirs();
}
If you wanna create another folder into that :
File f1 = new File(Environment.getExternalStorageDirectory() + "/" + folder_main, "product1");
if (!f1.exists()) {
f1.mkdirs();
}
Android 11 doesn't create app directory on external storage
Ok, I found a way to do it. Our app cannot create that folder but if we call for example getApplicationContext().getExternalFilesDir("");
Android will create that folder for us.
Quite stupid that if we want open dir which doesn't exist it will create it but when we want create it by ourself there is a problem. Android devs should makes our life easier but they making it more difficult with every update.
Android 11 - Creating app-specific directory on external storage
They are referring to creating arbitrary directories off of the external storage root (e.g., Environment.getExternalStorageDirectory()
.
getExternalFilesDir()
and similar methods on Context
are fine solutions to use instead!
Related Topics
How to Start Android Application on Device Boot
How to Show the Number Keyboard on an Edittext in Android
How to Disable Cache in Android Webview
Decrease Image Size Without Losing Its Quality in Android
Flutter:Renderbox Was Not Laid Out: Renderrepaintboundary#58C65 Relayoutboundary=Up1 Needs-Paint
Failure Install Parse Failed Manifest Malformed
Add Text to Image in Android Programmatically
How to Know When My App Has Been Killed
Clear Cache in Android Application Programmatically
How to Get the Height of Recyclerview Item in "Onbindviewholder"
How to Change Listview Height Dynamically in Android
Changing Background Color of the Layout on a Button Click in Android
Recyclerview No Adapter Attached; Skipping Layout
How to Tell If a View Is Visible on Screen in Android
Android: Open a Pdf from My App Using the Built in Pdf Viewer
How to Access the Camera from Within a Webview