Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

copy local storage to file system

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.

Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

copy local storage to file system

Any ideas ?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

copy local storage to file system

Hi Bob,

Yes you can.

Here is a brief plan:

  1. get all needed elements from local storage,

  2. combine these element to single object

  3. stringify this object into JSON. With following JS code:

    pre

    //That's your object
    var objectToStringify = {};

    var sjonString = JSON.stringify(objectToStringify );

    /pre

  4. 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.

Bob Fludder
Posts: 0
Joined: Fri Sep 14, 2012 1:09 am

copy local storage to file system

Thanks Yurii. It all seems too simple.

Return to “Issues”