Closed akkumar closed 4 months ago
In case it helps further - development on Ubuntu
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
My guess is your created files have permissions / ownership making them invisible for your app. I don't think there is a bug in the library, as the readdir()
implementation for Android is quite straightforward: https://github.com/birdofpreyru/react-native-fs/blob/70c3e0bafddbe98878c7e7dddf1f2acc8b09c64a/android/src/main/java/com/drpogodin/reactnativefs/ReactNativeFsModule.kt#L513-L536, if it does not include some files, it means file.listFiles()
at the line 519 doesn't include them into results.
Also, have you tried to google your problem before asking here? I see there is a bunch of similar questions in the first search results:
And, perhaps, the only way to access files on external storage in Android is to use the system-provided file-picker, i.e. see pickFile() method.
Working on
RN 0.74.1
Emulator: - Pixel 8 API 33
Version: Android 33
In Android Studio, use "View" -> Tool Windows -> Device Explorer.
My AndroidManifest.xml reads as below -
Updated:
Also have added -
<application ... android:requestLegacyExternalStorage="true" ..> ....
Problem:
In my app, using the RNFS api -
RNFS.readdir(RNFS.ExternalStorageDirectoryPath + "/Documents")
In the list of entries returned by the API - it returns the newly created directory - but not the 2 files.
It gets even more weirder.
If I do a
RNFS.exists(RNFS.ExternalStorageDirectoryPath + "/Documents/sample.docx")
it certainly returns 'true' as it rightfully should.
If that is the case - why would it not return that file in
RNFS.readdir(RNFS.ExternalStorageDirectoryPath + "/Documents")
api call ?Weird behavior.
What could I be doing wrong here ?
ps: Yes - trying to create a file manager here for a use case.