ContextCompat.getExternalFilesDirs (context, null) says:
Returns the absolute paths to directories of specific applications on all external storage devices, where the application can host permanent files that it owns.
For example, Huawei Honor running Android 5.1.1 returns the following from this method:
/storage/emulated/0/Android/data/my.package.name/files
/storage/sdcard1/Android/data/my.package.name/files
The second directory is a removable SD card. However, if I try to read or write to this directory, I get an exception:android.system.ErrnoException: open failed: EACCES (Permission denied)
The application has one WRITE_EXTERNAL_STORAGE. And it works great on Samsung Galaxy Note 4 running Android 4.4.4. This is not related to the additional permissions of Android 6.0, as this is the problem shown in 5.1.1.
The API says the application can place persistent files it owns, but it doesn't seem to be that way.
, Samsung. OEM- -, Android- ?
, .
File removable = ContextCompat.getExternalFilesDirs(context, null)[1];
if (removable.exists() && removable.canRead() && removable.canWrite()) {
File test = new File(removable, "test");
test.createNewFile();
}
, mkdir .