简体   繁体   中英

How to List all Internal Storage Folders in Android Q (API Level 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM