Starting from Android M, the external SD Card used as portable storage shows the SDCard ID as DocumentsContract first parameter.
So docId has the following format: XXXX-XXXX:path/to/the/file
And the real path would be: /storage/XXXX-XXXX/path/to/the/file
if (type.matches("[A-F0-9]{4}-[A-F0-9]{4}")) {
return "/storage/".concat(type).concat("/").concat(split[1]);
}
Tested on Moto X Play 6.0. Someone can confirm that it's the same for other devices? I don't like at all handwrite the "storage" path, and maybe the type is not always an SDCard ID.
I just see https://github.com/iPaulPro/aFileChooser/pull/78 that fix the problem. It loops the mounted volumes using reflection of android.os.storage.StorageVolume and return the path for the first occurence.
Starting from Android M, the external SD Card used as portable storage shows the SDCard ID as DocumentsContract first parameter.
So docId has the following format:
XXXX-XXXX:path/to/the/file
And the real path would be:/storage/XXXX-XXXX/path/to/the/file
Tested on Moto X Play 6.0. Someone can confirm that it's the same for other devices? I don't like at all handwrite the "storage" path, and maybe the type is not always an SDCard ID.
We should discuss this before merge.