Closed EternityForest closed 2 years ago
I believe I have the problem traced to DocumentsContract.getTreeDocumentId, and fixed using Foobnix's fix from https://stackoverflow.com/questions/41096332/issues-traversing-through-directory-hierarchy-with-android-storage-access-framew
Closed by #59
Describe the bug
When I call the listFiles() method of a document, I get a list of files in that document's root(The one that was obtained via openDocumentTree()).
From the documentation, it doesn't seem like there is any way to get the list of files in a subfolder.
To Reproduce
Get a uri with openDocumentTree, then call listFiles on any subfolder.
The returned list will be that of the top-level document.
Expected behavior
The listing should be a list of files in the subfolder, or, if there is some other way to list a subfolder, this should be documented.
Relevant Links
It seems like there is or was some kind of bug in DocumentFile itself? Is it possible something else can override the build.gradle and pull in the buggy 1.0.0?
https://stackoverflow.com/questions/62375696/unexpected-behavior-when-documentfile-fromtreeuri-is-called-on-uri-of-subdirec
Here we have someone saying they still saw it on what they thought was 1.0.1 : https://issuetracker.google.com/issues/37081745
Further references to v1.0.1, and discussion of possible workarounds using singleUri: https://stackoverflow.com/questions/46180851/get-a-documentfile-that-is-a-child-of-a-document-tree-without-using-findfiles
Reference to using DocumentsContract to get around the weird URI behavior:
https://www.reddit.com/r/androiddev/comments/k1etf7/is_it_possible_to_recreate_a_documentfile_folder/?utm_medium=android_app&utm_source=share
And finally, in case someone as new as me to the whole Dart/Android thing takes on this, here is how one can list using a documents contract: https://stackoverflow.com/questions/58201003/how-do-i-get-children-of-a-document-in-android-sorted-by-name
The issue seems to be, as far as I can tell, that fromTreeUri in Kotlin does not give a Document representing the Uri, it gives you the root, so doing the listing via a DocumentsContract should work. Perhaps I'll play around with this tomorrow.