leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Saving to file

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving to file

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.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Saving to file

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving to file

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Saving to file

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.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Saving to file

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?
Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Saving to file

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

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Saving to file

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

Return to “Issues”