I have a problem with creating files in Android. I have followed this tutorial, and wrote this method:
public File getStorageDir(String name) {
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).toString();
File file = new File(path, name);
System.out.println(path);
if (!file.mkdirs()) {
System.out.println("Directory not created");
}
return file;
}
Path variable prints /storage/emulated/0/Documents, however if goes off and no such directory is created. I have added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
permissions to manifest file. I have tried using file.getParentFile().mkdirs() but got same result. What am I doing wrong?