Android 11.0 : How to list all files from external storage efficiently?

I am new to this area (android application), and I am having enough trouble listing all the files on my phone. I activated the necessary options, and properly wire my phone to my computer, to test my application directly on my phone and not on an emulator.

My goal is very simple, I would like to recover all the video files, photos, documents ... as well as their size. I'll store all of this in a multihashmap (guava library), then perform multiple operations to remove all duplicate files.

First, I would like to list all files with one method. Then in a second step (to optimize), I would like to list only the files of the same type (all the photos together in hashmultimap, all the videos together ...).

However, I am having a little trouble understanding how this works. I have used badly algorithm which lists my files recursively on my computer, but they don't work on android. I have also done a lot of internet research, but most of the algorithms and tips are valid for Android 10.0 api lvl 29, and I'm with Android 11.0 api lvl 30.

Thank you in advance for your help.

Read more here:

Content Attribution

This content was originally published by Antoine Hazebrouck at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: