I see that some devices have the "Documents" folder and others do not, depending on the Android version
How can it be detected if the Documents
folder exists and if it does not exist to create it?
It is for an app that I need to store files in the file system and that I can use in other apps.
I have the following to detect the absolute path:
File outDir;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
outDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).toString());
} else {
outDir = new File(Environment.getExternalStoragePublicDirectory("Documents").toString());
}
with that you get:
/ storage / sdcard0 / Documents