Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Fix for external SDCard on Android M #79

Closed
wants to merge 1 commit into from

Conversation

jahertor
Copy link

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.

We should discuss this before merge.

@jahertor
Copy link
Author

I just see #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.

@jahertor jahertor closed this Mar 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant