Unable to update local json file in React native app

416 Views Asked by At

My React Native app file structure looks like this:

/assests
   /json
      example.json
/components
   view.js

I need to take input from the user in the view.js component and store it in the example.json file for future use. I tried using react-native-fs but could not figure out how to use it to get the absolute path of example.json and the relative path kept on throwing errors. If there is some other way to do this, it would be most appreciated.

Thanks in advance for the help!!!!

1

There are 1 best solutions below

0
On BEST ANSWER

Found out what the problem was. I was trying to update files that are in the app bundle and forgot that they are read-only. So I copied the files from the app bundle to the document directory and is accessible from there. I can edit and delete from there.