I have an app with a database full of information. The user never changes or adds anything to this database. I would like to update the database myself and store it on the web. Then everytime the app loads, it will check the web for a new version. If there is one, it would simply download it and replace it. What is the best way of doing this?
4 Answers
Someone else will have to tell ya the best way to initiate the actual download, but this blog post may be helpful in figuring out how to install the database once downloaded.
Also, you may find this question I posted earlier useful in determining database versions, basically I'm just parsing the file name to determine version. I'm sure there's an easier way for you though if you're communicating with a server.

- 1
- 1

- 14,970
- 9
- 43
- 57
-
I actually used that blog post to create my database. I like the idea of parsing out the filename and doing it that way. The updates may have hundreds or more new rows added and I would hate to have to write sql statements for all of those then execute them. I'd rather just overwite the existing database. – Mark Jun 07 '11 at 14:47
-
I know it has been a while, but I have tried this and it has worked great. I just parse the file names out and it grabs the newest one, then replaces the existing database on the device. – Mark Dec 28 '11 at 05:04
You got several options to tackle this problem:
- Download a xml or json file from your webserver, parse it, clear current database and import new data.
- You could directly save a text file on your webserver with sql statements and directly execute this prepped sql file to you sqlite database.

- 72,737
- 23
- 84
- 91
-
The updates may add hundreds or more rows to the database. I would like to just replace it each time instead of writing that many sql statements. – Mark Jun 07 '11 at 16:01
-
I'm not sure that's possible, will check that out! But is it really that bad? You could write a service running in another thread and handle those inserts in the background... – Sander Versluys Jun 09 '11 at 18:41
Well, you can update the whole apk via internet just checking it's version and checksum, and every new version should contain new DB version and necessary instructions which can be executed with a little help of SQLiteOpenHelper Or you can update your db via simple XML container over HTTP...

- 2,093
- 16
- 15
you can have a separate table in each dbs to keep the version updating. so every time you load the app you can call a web service and get the current version of the db which you store in the web server. if its newer than the db which you have, you can simply replace it.
you can use .Net web service which has the method to get the version of the db which stores in web, and with the help of ksoap library you can invoke the .Net web service and get the results.

- 4,493
- 1
- 16
- 15