Page 1 of 1

Saving to file

Posted: Fri Apr 19, 2013 5:02 pm
by leonardo

I am currently setting up my REST service using Echo to attach my xml files. My app has a need to save file in these 2 cases:

  1. Save to a new file (xml or text) or modify it--which will hold setup information

  2. Append to an xml file that is in use

    How can I accomplish these?


Saving to file

Posted: Fri Apr 19, 2013 5:56 pm
by maxkatz

Do you need to save a file on the phone? Some browsers offer File API.. so you can try that. I don't believe all browser support it yet.


Saving to file

Posted: Fri Apr 19, 2013 6:11 pm
by leonardo

Yes, this would be saving in on IOS and Android devices. I know some apps I use on those devices do it.


Saving to file

Posted: Fri Apr 19, 2013 6:12 pm
by maxkatz

I'd check the File API.. you can also see what PhoneGap provides.


Saving to file

Posted: Fri Apr 19, 2013 6:24 pm
by Maryna Brodina

Hi, just to add to what Max said:
1) maybe it will be enough for you to use localStorage, if you still need to save in file - it's quite complicated, but this should help http://docs.phonegap.com/en/2.4.0/cor...
2) you can set up REST service to work with json, it would be easier to work with json in JS then work with xml.


Saving to file

Posted: Fri Apr 19, 2013 6:53 pm
by leonardo

Thanks.

  1. With localStorage, doesn't the variable reset at each session or at least reboot? For example if I want to setup a date that I am starting a multi-level routine so I can pickup on the right schedule each time, can I use localStorage for that?
  2. Do you have a pointer or reference on this?

Saving to file

Posted: Fri Apr 19, 2013 7:42 pm
by Maryna Brodina

1) localStorage data stays saved after reboot
2) to set us REST service to work with json just set Data Type = json in service settings. To save object as json to localStorage you should convert it to string
codelocalStorage.setItem("obj", JSON.stringify(obj));/code
to get saved object codevar obj = JSON.parse(localStorage.getItem("obj"))/code


Saving to file

Posted: Fri Apr 19, 2013 8:38 pm
by leonardo

Beautiful. Bless you, Marina! I'll give it a spin.