copy local storage to file system
Posted: Thu Feb 26, 2015 1:28 am
by Bob Fludder
I have a number of entries that are currently being saved in local storage and at a certain time are sent via a rest request to our server. Works perfectly. Is there a way of copying this same information into the file system (say "uploads") in the phone itself ? I'm using android if that helps. It's so you can connect a pc to the phone with a usb cable, and then be able to copy the file to the pc.
copy local storage to file system
Posted: Fri Feb 27, 2015 5:35 am
by Bob Fludder
copy local storage to file system
Posted: Fri Feb 27, 2015 5:51 am
by Yurii Orishchuk
Hi Bob,
Yes you can.
Here is a brief plan:
get all needed elements from local storage,
combine these element to single object
stringify this object into JSON. With following JS code:
pre
//That's your object
var objectToStringify = {};
var sjonString = JSON.stringify(objectToStringify );
/pre
Okay, this time you can save this string into the local file using preinstalled plugin "org.apache.cordova.file"
Details: https://github.com/apache/cordova-plu...
Regards.
copy local storage to file system
Posted: Fri Feb 27, 2015 6:36 am
by Bob Fludder
Thanks Yurii. It all seems too simple.