问题描述
我是编程新手,想在android studio中制作文件管理器.在不推荐使用getExteralStorageDirectory
后,我在列出API级别29中的所有设备文件夹时遇到问题.
I am new in programming and want to make a file manager in android studio. I am facing problems in listing all device folders in API level 29 after getExteralStorageDirectory
was deprecated.
推荐答案
根据文档,则必须使用 ACTION_OPEN_DOCUMENT_TREE .这将为您提供所选directory
的URI
,一旦您拥有URI
,您就可以访问该directory
的所有子级.来自文档
According to the documentation, you will have to use ACTION_OPEN_DOCUMENT_TREE. This will provide you with the URI
of selected directory
, once you have the URI
then you can access all the children of that directory
. From docs
在github上还有 ActionOpenDocumentTree 示例应用程序,展示了如何实现此功能.
There is also ActionOpenDocumentTree sample app on github which shows how to implement this feature.
这篇关于如何列出Android Q(API级别29)中的所有内部存储文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!