相关文章推荐
另类的开水瓶  ·  Qt Creator ...·  1 年前    · 
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

How are you using this? have you tried with this [ let path = RNFetchBlob.fs.asset('bundle-assets://my-asset.jpg'); ] – Nooruddin Lakhani Oct 19, 2020 at 5:59 RNFetchBlob.fs.asset return string. lets say let string = RNFetchBlob.fs.asset('my-asset.jpg') .where string is just 'bundle-assets://my-asset.jpg' – Nur Oct 19, 2020 at 9:25

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.