简体   繁体   中英

Unable to get files from folder with .nomedia file or hidden folder in Android 11

I want to get all files from WhatsApp's .Statuses folder. Until Android 10 im perfectly getting all statuses files. But on Android 11 due to new restrictions, when I code like below:

File(Environment.getExternalStorageDirectory().absolutePath + File.separator + "Android/media/com.whatsapp/WhatsApp/Media/.Statuses").listFiles()

I always get 0 files. Whereas, Im successfully getting other folder files "Android/media/com.whatsapp/WhatsApp/Media/" on this path.

Two problems I'm facing now:

  1. If a folder is hidden then in Android 11, listFiles() returns 0 on that folder.
  2. If a folder not hidden but contains one file as ".nomedia" , listFiles() returns 0 on that folder as well in Android 11.

What should I do to get all whatsapp statuses files in Android 11?

I dont want to use MANAGE_EXTERNAL_STORAGE permission for it due to google policies. Thank you

Getting same problem. Any solution ?

There are ways to access Hidden Directory in Android 11 , two of them are:

  1. Storage access framework (SAF) in which you take user to that specific directory and ask for permission from user to access directory files and that way you get access to files in it (Study SAF).

  2. You can use File Observer on that hidden folder and whenever any file created or modified or deleted from that hidden directory you will get full path in that case for that specific file in hidden folder & once you have full path you can have access to that file.

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