You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm calling DocumentFileCompat.fromTreeUri, with an URI that already has a document: content://com.android.externalstorage.documents/tree/primary:azahar-emu/document/primary:azahar-emu/sdmc, however the code in TreeDocumentFileCompat.make does not check this and tries to build the document URI again. This discards the already built document URI and replaces it with the tree URI, creating: content://com.android.externalstorage.documents/tree/primary:azahar-emu/document/primary:azahar-emu (notice how sdmc part was lost).
A possible solution may be to check if the URI already is a document URI:
val treeUri = if (isInitial && !DocumentsContract.isDocumentUri(context, uri)) {
DocumentsContract.buildDocumentUriUsingTree(uri, DocumentsContract.getTreeDocumentId(uri))
} else {
uri
}