Cordova - how to read and write s file in the web application folder

306 Views Asked by At

I am with Cordova and JQuery to build an Android App.

I have a json file in /www/data/my file.json, and I need to read this file into front end index.html on the device ready event, also to overwrite this file as well from a button click as well.

Can anyone point me a direction what object of the Cordova file plugin I should use? An example would be really appreciated.

1

There are 1 best solutions below

0
andreszs On

The direction is the cordova-plugin-file, but good luck modifying files from the app package, which is impossible as far as I know... no app cannot rewrite itself that way.

To keep small JSON data, you should use localStorage, this is the easiest way and it does not require plugins. Refer to the localStorage limits before though.