【发布时间】:2020-06-25 22:08:42
【问题描述】:
如果我尝试解析 "String path=/storage/emulated/0/Somefolder/" 类型的字符串路径,则方法 Uri.parse 会生成一个不是 Android tree Uri 的 Uri。
因此,如果我尝试使用类似的东西获取DocumemtFile 列表
String path="/storage/emulated/0/Somefolder/"
DocumentFiles[] fileslist=DocumentFile.fromTreeUri(this, Uri.parse(path)).listFiles();
我收到 无效 URI 错误。
如果我尝试使用 DocumentFile.fromSingleUri 也不能正常工作。
如何从字符串路径中正确获取 tree Uri?
我找到了如何使用操作 Intent 获取 treeuri,但我需要以编程方式执行此操作,而不需要强制用户手动选择文件夹。
【问题讨论】:
标签: android uri storage-access-framework android-storage