'How to fetch files in hidden folder using Media Store API

I need to fetch data inside WhatsApp folders on External Storage. As I am targeting API Level 30 I am no longer able to access WhatsApp folders on External Storage. I have implemented the Storage Access Framework and got the Android/media folder Uri and Document File. And using listFiles() i am able to list files but with filter() and sortedByDescending() functions it becomes very slow.

What I have tried?

Used Cursor loader with Projection and Selection Arguments but it only worked for non-hidden folders like WhatsApp Images and WhatsApp Videos

It returns an empty cursor for the hidden folder.Statuses

Tried replacing MediaStore.Video.Media.EXTERNAL_CONTENT_URI with MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL)

How i can use MediaStore in this case so that i don't need to use sort and filter functions of list? Its not important to get java.io File only i can work with URIs as well.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source