How to List all Internal Storage Folders in Android Q (API Level 29)?

冷暖自知 提交于 2020-12-31 07:35:13

问题


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.


回答1:


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

Grant access to a directory's contents

File management and media-creation apps typically manage groups of files in a directory hierarchy. To provide this capability in your app, use the ACTION_OPEN_DOCUMENT_TREE intent action, which allows the user to grant access to an entire directory tree. Your app can then access any file in the selected directory and any of its sub-directories.

There is also ActionOpenDocumentTree sample app on github which shows how to implement this feature.



来源:https://stackoverflow.com/questions/61420960/how-to-list-all-internal-storage-folders-in-android-q-api-level-29

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!