3

In my iphone application i used sqlite3 for creating database. Now i want to take backup of a database file on my server.

so how to upload my sqlite db file to server from my application in iphone?

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
skyfall
  • 31
  • 2

1 Answers1

5

I would read the sql database into a JSON object, then upload it to a server via a URL that calls a PHP script along the lines of this stack overflow answer!

Here's an example of some mySQL data wrapped into JSON:

{database:{"col1":"56","col2":"85","col3":"some_text"},
{"col1":"57","col2":"86","col3":"next row"} }

More about JSON payloads in Apple dev docs here JSON

As of iOS5.x, Apple now includes some JSON helper classes, see NSJSONSerialization class reference along with the Twitter example app.

I have used this the SBJson framework in the past for iOS SBJson

Community
  • 1
  • 1
Nick T
  • 897
  • 8
  • 30
  • hello nick thanks for your reply.Instead of read sql database into a JSON object. I want to upload whole Sqlite db file similar to the upload image on server in iphone. It is possible or not. – skyfall Nov 02 '12 at 10:53
  • One option is to turn on file sharing via iTunes: See http://stackoverflow.com/questions/10241032/share-sqlite-with-itune-file-sharing-within-ios-app – Nick T Nov 08 '12 at 12:51