Skip to content

Solution for opening file on external SD card #1

@javlada

Description

@javlada

Thanks a lot for sharing the solution regarding opening files on Android. It helped me a lot. I found a solution which works at least for me regarding opening files on external drive (SD card, USB stick etc.). Please have a look my changed code in QSharePathResolver.java

            if (isExternalStorageDocument(uri)) {
                Log.d("Muzika"," isExternalStorageDocument");
                final String docId = DocumentsContract.getDocumentId(uri);
                final String[] split = docId.split(":");
                final String type = split[0];
                Log.d("Muzika","Storage type: "+type+" ,"+split[1]);
                if ("primary".equalsIgnoreCase(type)) {
                    return Environment.getExternalStorageDirectory() + "/" + split[1];
                }
                else {
                    return "/storage/"+type+"/"+split[1];
                }
            }

Is there a problem with this solution? Unfortunately I don't have enough devices to test it generally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions