how to get data / file out of an application?
I'd just like to know what the options are for getting data out of an application:
I've been creating an application with phonegap in html5 that works with an sqlite database, ideally i would like this app to write some of the contents of the database to a local xml file which can be sent from the device on which it is run by a file manager.
Is the correct way to achieve this via a plugin? Does such a plugin exist for iphone/ipad?
Also is there a backup universal method not involving plugins i can use purely with html5 in which i can send contents of the db via开发者_开发百科 email or some other method easily?
Any advice or input on this would be very much appreciated, thanks!
It's very easy to create JSON data which is ideal for sending to a web service or writing to a file. XML is a lot harder. The information stored in your iOS classes like NSArray, NSDictionary etc is sent in the JSON.
Excellent free JSON library here.
Once you install you create a JSON string from iOS objects or iOS objects from a JSON string with one method. A good (if old) tutorial is here.
Consider reading the data from your database, packaging it as JSON, and sending it to your server using HTTP PUT or POST. You can do all of this within javascript.
To make things even easier, look into using a javascript library called jQuery. Develop and test it using safari, and drop it into your phonegap app when it's ready.
精彩评论