0

I am facing an issue with hidden folders starting with a dot. I want to access the WhatsApp .statuses folder but when I add the path it does not give me the files in that folder.

I am using rn-fetch-blob package. Below is the code for that:

RNFetchBlob.fs
    .ls(`${dirs.SDCardDir}/Android/media/com.whatsapp/WhatsApp/Media/.statuses`)
    .then(data => {
      console.log('data => ', data);

    })
    .catch(error => {
      console.log(error);
    });

It gives me an empty array.

But

If I rename the folder to statuses and remove the dot then the fetches the images in that folder. Like below:

data =>  ["IMG-20201015-WA0003.jpg", "IMG-20201015-WA0002.jpg"]

Can anyone please help me in resolving this issue?

I can provide more details if required. Thanks!!!

robert_45
  • 55
  • 1
  • 6

1 Answers1

0

I am able to access the same folder starting with a dot but I don't think the dot is the problem but the permission is.

 const path = `${RNFetchBlob.fs.dirs.SDCardDir}/Android/media/com.whatsapp/WhatsApp/Media/.Statuses`;
 console.log('path => ', path);
 RNFetchBlob.fs.ls(path)
 .then(data => {
  console.log('data => ', data);
 })
 .catch(error => {
  console.log(error);
 });

Permissions:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/> //to test on Android 11.

Output:

 LOG  Running "TestProject" with {"rootTag":11}
 LOG  path =>  /storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/.Statuses
 LOG  data =>  ["29373787dadf4c5eb21337456a5d949b.mp4", "e44025a00ceb4ef7854145da9621ba49.jpg", "a2f1a25d3a0842b294e36dbe48ad18dd.jpg", "5d0d04c3d369483b9f855e7f3522de6a.jpg", "91fd9117527c4ef88182458dcdc23e70.jpg", "df5c6309de994da9aa54b13a79a71568.jpg", "31570f0c284e401899afcc74aa3ff70d.mp4", "40a31c5dd94c412a816e2a5188ad253e.jpg", "0455956fe743486099d8a8f745e022d1.jpg", "6597bba6de514247af2eb900eb9fbed9.jpg", "3c609d8c5f0a4fdfbff8cef73deff525.jpg", ".nomedia", "f9fcf71ab20c484f9bf92bbae3efcab2.jpg"]
Satheesh
  • 10,998
  • 6
  • 50
  • 93
  • Hi Satheesh, Can you specifically tell me in which file should I write these premissions? I am totally new to React Native. – robert_45 Jun 06 '22 at 10:39
  • android/app/src/main/AndroidManifest.xml – Satheesh Jun 06 '22 at 10:50
  • Again please read more about Storage changes to Android 10 and Android 11. The way things work is really different. Check out https://stackoverflow.com/questions/65934372/android-11-not-showing-whatsapp-status-in-app-storage-emulated-0-whatsapp-medi – Satheesh Jun 06 '22 at 10:51
  • I have added the permissions in the file but it is not giving the date, once I remove the dot it gives an array of all images. – robert_45 Jun 06 '22 at 12:39
  • I also see that it is .statuses in your code and .Statuses in mine. S is the upper case in the actual folder on my device. – Satheesh Jun 07 '22 at 08:18
  • I have tried with both. Even I have created a .test folder, it does not work with that also. – robert_45 Jun 07 '22 at 09:53
  • Once I remove the dot it get all the files in that folder. – robert_45 Jun 07 '22 at 09:53