4

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

Ali Jzz
  • 51
  • 5
  • You will only see files that your app created. Or some media files. Android 11. – blackapps Jul 26 '21 at 10:48
  • But im successfully getting all files of whatsapp folders at path "Android/media/com.whatsapp/WhatsApp/Media/..." in Android 11. Just my concern is why Android 11 does not allow access to .Statuses folder files? – Ali Jzz Jul 26 '21 at 10:57
  • Put a .nomedia file in the first one. What happens? – blackapps Jul 26 '21 at 11:18
  • @blackapps If I just for checking, add a simple file with name .nomedia in a folder which is not hidden then that folder also started to return 0 in listFiles() which was getting all files perfectly when there is no .nomedia file in that folder (Android 11). Which means Android 11 somehow restricting to access folders 1) Hidden 2) With .nomedia file or may be there is some other way to access these kind of folders. – Ali Jzz Jul 26 '21 at 11:25
  • One more thing listFiles() even returning 0 if only the folder is hidden in Android 11 with no .nomedia file in it. Which means these are total 2 cases. 1) Hidden 2) With .nomedia @blackapps – Ali Jzz Jul 26 '21 at 11:28
  • 2
    Same issue. Any answers? – Dulaj Madusanka Jan 04 '22 at 05:26
  • @DulajMadusanka yeah there can be ways, one of them is through: 1) Storage access framework (SAF) in which you take user to that specific directory and ask for permission from user and that way you get access to files in it. OR 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. – Ali Jzz Jan 05 '22 at 05:52

1 Answers1

1

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.

Ali Jzz
  • 51
  • 5