I have a very strange bug with private external storage on tests run only on Saucelabs. It doesn't happen on real devices.
This works:
val externalStorageVolumes: Array<out File> = ContextCompat.getExternalFilesDirs(applicationContext, "documents")
val documents = externalStorageVolumes[0]
val fileFolder = File(documents, "file")
val fileFolderResult = fileFolder.mkdirs()
This doesn't work:
val documents = File(applicationContext.getExternalFilesDir(null), "documents")
val documentsMkdirResult = documents.mkdirs()
val fileFolder = File(documents, "file")
val fileFolderResult = fileFolder.mkdirs()
Only on their Tab S7/S8 devices and not on my Tab S7/S8, I get this error:
Primary directory null not allowed for content://media/external_primary/file; allowed directories are [Download, Documents]
but nothing in the official documentation seems to correlate the warning to the code:
https://developer.android.com/training/data-storage/app-specific#kotlin