I am downloading files using DownloadManager to a directory, that isn't apart of my "local packages" directory, i.e. outside /storage/emulated/0/Android/data/myPackageName/, but part of another directory's package, more specifically, obb directory, /storage/emulated/0/Android/obb/otherPackageName/
If I install on "my package's directory", no problem, if I got outside of it, I get a "java.lang.SecurityException: Unsupported path /storage/emulated/0/Android/obb/otherPackageName/fileName.obb"
I have my permissions in the android manifest, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE, and I check if I have them using ContextCompat.checkSelfPermission and see if it equals PackageManager.PERMISSION_GRANTED, which it does. But if it didn't, and for API level>=23, I use something along the lines of
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE}, CODE);
And then I use onRequestPermissionsResult() to check the response and see if it is a PackageManager.PERMISSION_GRANTED, so that I may be able to start the download.
Even with this, I am getting the exception. Can this be device specific or API specific? I'll have to test on other devices and API's to know for sure. Am I doing something wrong here? Do I need an extra permission? It has to be possible to write outside the directory?
Also, I am getting the external directory using Environment.getExternalStorageDirectory(), and then I add the subdirectories as a string (works for /storage/emulated/0/Android/data/myPackageName/..., but not for /storage/emulated/0/Android/obb/otherPackageName/...)
Thank you for reading, lemme know if you need any information.