Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have some data in
android\app\src\main\assets
and I am using
rn-fetch-blob
as filesystem.
But what is the schema path to
assets
folder in android? How to read data from it?
Is there any other way to ship pre pupolate data file in react-native ? Can I place file in react-native project root directory?
There is
readFileAssets
is a method in
react-native-fs
.
Place your file in
android\app\src\main\assets
.If there is no
assets
folder
then just create it.
import fs from "react-native-fs";
fs.readFileAssets("folder/file", "base64") // 'base64' for binary
.then(binary => {
// work with it
.catch(console.error)
Note: Path must be relative. If android\app\src\main\assets\folder\file
then use folder\file
let path = RNFetchBlob.fs.asset('my-asset.jpg')
RNFetchBlob.fs.asset('bundle-assets://my-asset.jpg');
There is a method in doc assetfilenamestrings
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.