How to get the real path with ACTION_OPEN_DOCUMENT_TREE Intent?

前端 未结 1 1674
梦如初夏
梦如初夏 2020-12-11 15:18

My app downloads and unzips a file in a specific folder:

output = new FileOutputStream(realpath, true);
output.write(buffer, 0, bytesRead);

ZipFile zipFile          


        
相关标签:
1条回答
  • 2020-12-11 15:29

    Process of getting real Path from URI is same as before, but with a little addition:

    Uri uri = data.getData();
    Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri, 
                            DocumentsContract.getTreeDocumentId(uri));
    String path = getPath(this, docUri);
    

    The gist of getPath() method with intermediate methods can be found here: getPath()

    0 讨论(0)
提交回复
热议问题