The method Uri.parse
generates an Uri that is not an Android tree Uri if I try to parse a String path of the kind "String path=/storage/emulated/0/Somefolder/"
.
For this reason if I try to get DocumemtFile
list with something like
String path="/storage/emulated/0/Somefolder/"
DocumentFiles[] fileslist=DocumentFile.fromTreeUri(this, Uri.parse(path)).listFiles();
I get Invalid URI error.
And if instead I try to use DocumentFile.fromSingleUri
doesn't work correctly too.
How Could I get the tree Uri correctly from a String path?
I have found how to get the treeuri using action Intent , but I need to do this programmatically without the needs of forcing the user to choose the folder manually.