itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.96k stars 983 forks source link

Can't access files of hidden folder. #981

Open Shashank-Salian opened 3 years ago

Shashank-Salian commented 3 years ago

I am not able to access files from a hidden folder /WhatsApp/Media/.Statuses in react-native-fs. Whenever I access I get back an empty array. I have granted READ_EXTERNAL_STORAGE permission. My code goes like this :

import RNFS from 'react-native-fs'
RNFS.readDir(`${RNFS.ExternalStorageDirectoryPath}/WhatsApp/Media/.Statuses`).then(res => {
    console.log(res)    // logs : []
})

I am able to access files of other folder but not anything that starts from '.'
How to access files of a hidden folder in react-native-fs ?

Update: This issue is in Android 11. Probably Android 10 as well.

myckhel commented 3 years ago

Checkout answer for solution: https://stackoverflow.com/a/68364888/9241085

Problem resolved for me by adding following permission in AndroidManifest.xml

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

Visit to learn more https://developer.android.com/training/data-storage/manage-all-files#all-files-access

cetric32 commented 3 years ago

I have tried above solution but not working for me Am using android 11

iqbalprasas commented 3 years ago

You need to add additional permission called MANAGE_EXTERNAL_STORAGE, you can see in this post

https://stackoverflow.com/a/69820147/10851423