Is it possible to create directory in directory. To create one directory simply call this:
File dir1 = getDir("dir1",Context.MODE_PRIVATE);
But how to create other directory in dir1
?
this:
File dir2 =getDir("dir1"+"/"+"dir2",Context.MODE_PRIVATE);
throw exception:
File dirFile = java.lang.IllegalArgumentException: File app_dir1/dir2 contains a path separator
Thanks.
The Context.getDir() appears to be an Android-unique method for abstracting out the process of creating a directory within the private storage area - it is not a generic way of making directories in general.
To make your child subdirectory, you should use normal java methods, such as
File dir2 =new File(dir1, "dir2").mkdir();
Note that the first parameter here is the File Object representing the first directory you created, not the name.
You may want to subsequently set the permissions on this directory.
warning: untested
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With