0
I’m using the following code to create a directory when the user presses a button inside a Fragment, but it’s still not working, and I don’t know why.
File dir = new File("/novaPasta");
try{
if(dir.mkdir()) {
System.out.println("diretorio criado");
} else {
System.out.println("diretorio não criado");
}
}catch(Exception e){
e.printStackTrace();
}
and I am using the following permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
I have no error in the log, only the message that the directory was not created
https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory() [...]
– Lennoard Silva
[...] that is to say,
new File(Environment.getExternalStorageDirectory(), "novaPasta").mkdir()
create a folder named "Novafolder" in the internal memory– Lennoard Silva