Sana Joseph
Sana Joseph

Reputation: 1948

How to connect sqlite with an online database on Phonegap

I made a database using phonegap[cordova 1.7.0] sqlite on IOS5. But I now want to switch this database with one that I already have on an online server. Is there some method to do that ?

Thanks a lot.

Upvotes: 3

Views: 2235

Answers (4)

dda
dda

Reputation: 6203

There's an sqlite plugin for Phonegap. If the online sqlite is (semi-)publicly available/downloadable, you could have the Phonegap download the db file (there's a Download plugin, I think), and have your customized sqlite plugin use this db.

Upvotes: 2

MeTTeO
MeTTeO

Reputation: 2098

If I understood correctly you want to use your current logic for handling database access to connect to remote sqlite database.

I think such use case is not possible out of the box. Cordova is using support for WebSQL built into iOS and Android (or provides own compatible implementation).

There are at least 2 solutions to your problem:

  1. Create service which allows access to your remote database, and then create client side sync service which synchronizes that on the client and server. This way you will have full offline support plus data will be backed up on the server.

  2. Write your own Cordova plugin which allows access to remote sqlite databases but uses WebSQL interface. I guess you could reuse most of the current logic from iOS WebSQL implementation, but instead of accessing local sqlite file on the device, use the database on the server.

Upvotes: 2

gmh04
gmh04

Reputation: 1351

Write a server side application that provides access to the database.

Upvotes: 2

Neji
Neji

Reputation: 6839

Either you can also do it in this way. Create a XML file dbase on server and parse it then you can make changes to your existing database by reading the xml files contents.

Upvotes: 1

Related Questions