I'm still searching, but maybe anyone faced with the same issue.
I'm maintaining an app. This app stores some data in two places (lets say on sdcard/example and external_memory/example). Before the migration to the newest Android Api everything worked fine using ExternalStorage.getAllExternalStoragePaths()
. Now I'm still able to get both paths, but the sdcard/example path is not readable and not writable..
I read about the SAF, but in my case that is not a solution - the files stored in both directories are parsed using a native library (C++) - I need path to it like /storage/sdcard/example/test.xml
. Otherwise the library is not able to read this file. Unfortunately I cannot change the library because of missing sources.
I would like to ask three questions:
Moving files to /storage/sdcard/Android/data/com.example/files/
is not acceptable by stakeholders.
Is there any other way to ask access to directory on SD Card and use this directory like the old way?
No, short of building a custom ROM or rooting the device.
Maybe I can say Android - "hey, I want have Example directory on SD Card and maintain it"?
No. The closest thing is getExternalFilesDirs()
, getExternalCacheDirs()
, and getExternalMediaDirs()
. If those return 2+ items, the second and subsequent ones will be on removable media, and you can read and write to those paths. However, you do not control what the paths are.
Or maybe I can use SAF without ContentResolver?
No, insofar as you cannot get a filesystem path.