Questions tagged [mkdirs]
87 questions
28
votes
11 answers
android mkdirs not working
i need to save an image from camera on android.
i used the write external storage permission in manifest and i am using this code
File dir = new File(Environment.getExternalStorageDirectory(), "Test");
if (!dir.exists() || !dir.isDirectory())
…

lallous34
- 483
- 1
- 4
- 12
23
votes
1 answer
mkdirs() return value for already existing directories
File.mkdirs JavaDocs:
public boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the…

Davio
- 4,609
- 2
- 31
- 58
21
votes
2 answers
C# equivalent of Java's mkdirs()
I am trying to convert a Java program to c#.
Is there a equivalent to Java's mkdirs() command which recursively makes folders?

Ian Vink
- 66,960
- 104
- 341
- 555
17
votes
2 answers
saving file in internal storage android
i'm new to android, and i'm having a problem when i'm trying to save a file into internal storage, the new example works on my sdk, but doesn't work on my phone.
I'm trying to run de example in a sony Ericsson xperia, with android 2.1 by the way...…

Fede
- 1,656
- 4
- 24
- 42
8
votes
5 answers
mkdir in ant fails. How can i handle this error
The ANT build script I have does the following:
Perform the builds on Windows server & Zip the binaries
Map a network drive with different credentials to a local drive (ex P:) using net use
I am using to create a directory on the mounted…

KK99
- 1,971
- 7
- 31
- 64
7
votes
5 answers
Android mkdirs() creates a zero byte file instead of a folder
In my android application, I am trying to create the following folder on the sdcard:
/mnt/sdcard/OSGiComponents/admin/felix-cache/
Here's the code:
File cacheDir =
new File( Environment.getExternalStorageDirectory().getAbsolutePath() +
…

Kartik Sankaran
- 290
- 3
- 11
6
votes
3 answers
mkdirs() function in multithreaded environment
I am creating tree of files and folder. I am rewriting to multithreading. The only weak point I see is when creating folders. Right now it goes one by one (in depth). Before I write down the file I check if the path exists. If not, I use mkdirs to…

Elis.jane
- 259
- 2
- 4
- 10
5
votes
1 answer
Unable to create directory on Android 6.0 with mkdirs (storage permission ok)
I'm trying to update my app source code to Android 6.0 with the new runtime permissions.
But also if the user grants to app the storage permission, the app is not able to create directories in the 'onRequestPermissionsResult' method using the…

Mirko
- 135
- 1
- 8
5
votes
2 answers
mkdir() returns false after deleting the folder
I have a button in my app called "Reset" which deletes an entire folder (user folder). After that, I am trying to create again the same folder and the first time I try it, it allows me to create the folder, but the second time I try to Reset and…

Mario Velasco
- 3,336
- 3
- 33
- 50
5
votes
2 answers
android mkdirs in SD card return false.help me, it spends me 3days
I want to create a folder in SD card ,and i already add the permission
in manifest file.below is my code,but mkdirs return false! Can you help me!
File exportDir = new…

user1951072
- 65
- 1
- 6
5
votes
2 answers
Android: unable to create a directory in default pictures folder
This is the code i am using to create a folder in the default pictures folder:
File imagesFolder = new File(Environment.DIRECTORY_PICTURES, "/images");
if (!imagesFolder.exists()) {
Log.d("if imagesFolder exists - 1",…

Archie.bpgc
- 23,812
- 38
- 150
- 226
5
votes
8 answers
How to write elegant code using File.mkdirs() in java?
I need a directory to save files but I am not sure whether it exists.
So I need to check if it exists first, and create it if necessary.
File saveDir = new File("/tmp/appname/savedir/");
if(!saveDir.exists()){
saveDir.mkdirs();
}
As above,…

kino lucky
- 1,365
- 4
- 15
- 24
3
votes
3 answers
mkdirs not working in windows 7
I made a small java app that copies a directory from a CD to the HD. I made the program using Windows Vista and it worked, but when i ran it in Windows 7, it fails.
The main problem is that a folder inside the Program Files folder needs to be…

user897013
- 165
- 1
- 3
- 9
3
votes
1 answer
Problem to create directory in Android
I'm developing a simple application for Android devices.
I need to create a directory, but I can't do it.
File folder = new File(Environment.getExternalStorageDirectory ()+"/dir");
if(folder.mkdirs()){
CrearToast("Directorio creado");…

Kanttarino
- 57
- 1
- 7
3
votes
2 answers
Android mkdirs() return false on Android 11 with Environment.getExternalStorageDirectory()
Mkdirs() function is not working on Android 11. every thing is working fine on Android 10 and lower.
Code:
***String path =Environment.getExternalStorageDirectory().getAbsolutePath() + "/My_directory/";
File temp_file = new File(path);
if…

صلي علي محمد - Atef Farouk
- 3,257
- 2
- 30
- 46