'How can I access to a folder with .nomedia file using Media Store APIs?

I'm trying to access media files using Media Store APIs , but I'm facing with a specific issue: I can scan all the audio files apart all the audio files belong to a folders with .nomedia files inside. As well-known .nomedia file doesn't allow a specific directory to be scanned. But if my application needs to read all the audio file as a core funcionality stored for example :

Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Voice Notes DualApp/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Voice Notes

is there any flag, any permission I need to request in order to access to these specific folders ? Otherwise which is the best practice in Android 11 to access audio media files present in the external storage ?

My first fix was to add the MANAGE_EXTERNAL_STORAGE permission, but my app was rejected with this statment:

You have requested access to All Files Access permission but it appears that your app's core feature requires access to only Media Files or does not need access to any Files. In case your app needs access to Media Files, with the MediaStore API, apps can contribute and access media that's available on an external storage volume without the need for the access all files permission. Please update your app so that the feature uses Media Store APIs and remove All Files Access (MANAGE_EXTERNAL_STORAGE) permission.

So in case, I cannot use MANAGE_EXTERNAL_STORAGE and the media folder has the .nomedia file inside, How can I scan/access the audio files inside that folder?



Sources

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

Source: Stack Overflow

Solution Source