I am using React Native 0.63. I wanted to display images in a FlatList from my phone's device storage and was using <Image/> for the renderItem prop of FlatList.
Using the source prop, I added a uri key but I am still not able to see the images. The image tiles are being generated in the FlatList and I am able to see the thin scrollbar on the right when I try to scroll over the list.
This is what I am doing to display the image. (The uri used here is of an image which I got from the CameraRoll.getPhotos() API)
<Image
source={{ uri: 'file:///storage/emulated/0/Pictures/Twitter/20201019_160855.jpg'}}
style={{ height: 100, width: 100 }}
/>
I have made sure about the following:
- Allowed
READ_EXTERNAL_STORAGEandWRITE_EXTERNAL_STORAGEpermissions for the application. - Added
file://prefix to the file. - Made sure
source={{ uri: ... }}in<Image/>works for external links, tried using Google logo, random jpegs from the internet.
Another thing which I noticed is, I am using Samsung phone with Android 10 on my device where I am facing this issue. I tried running this on the Google Nexus 5 Android Emulator which also runs on Android 10 and works perfectly fine (By this, I mean I am able to access the emulator's device storage and not using the exact same uri specified above).
UPDATE: Tried compiling the application on Android 7, the above thing is working fine. Any issue with the the SDK Versions?