I have a collection of images located in the assets folder within the Android directory, as depicted in the accompanying screenshot.
I would like to utilise those images without relying on the "require" function.
To access the images, you can utilise the ImageUri with the following format: "file://{ProjectDir}+{pathToImage}". This approach allows you to reference the images directly without the need for the "require" function.
Unfortunately, I'm encountering difficulties with the implementation, and I'm struggling to establish the appropriate image path.
I have made numerous attempts to address this issue, as evident from the following examples of what I have tried so far.
1:
const documentDirectoryPath = RNFS.MainBundlePath;
const relativePath = 'assets/your_file.jpg';
const absolutePath = ${documentDirectoryPath}/${relativePath}
;
console.log('Absolute path:', absolutePath);
2:
import RNFS from 'react-native-fs';
const baseFilePath = RNFS.DocumentDirectoryPath;
const subdirectoryPath = ${baseFilePath}/your_subdirectory_name
;
const filePath = ${subdirectoryPath}/your_file_name.ext
;
console.log('Absolute file path:', filePath);