Android Question SQLITE structure update

prajinpraveen

Active Member
Licensed User
Longtime User
Hello all. what is the right way to push an update to the structure of the SQLITE database which already has data.

Eg: Version 1 of the app has a Database with 3 tables and 3 columns in each table. Version 1.2 of the app has upgrade and should modify the sqlite database to 4 tables with 4 columns each without deleting the existing data in the database
 

DonManfred

Expert
Licensed User
Longtime User
All ALTER commands you used to expand the database you need to use on the v1.0 dabase too. alter the databasetables, fields. then set the version of the database to 1.2 to check again when you release 1.3....
 
Upvote 0

prajinpraveen

Active Member
Licensed User
Longtime User
thank you, so the update of the db structure is handled via the code and the same database structure update is applied in all the following application updates, incase if the user has skipped a version (eg. if the user moves from version 1.0 to 1.3 skipping 1.1 and 1.2)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You need to create your own routine to check.

User have 1.0 but 1.1 and 1.2 are ignored to update.
The he get 1.3 and at first run YOU (your app) needs to find out which updates needs to be applied...
In fact your app need to
update v1.0 database to 1.1 (set version to 1.1)
update v1.1 database to 1.2 (set version to 1.2)
update v1.2 database to 1.3 (set version to 1.3)

And then you can use the database v1.3
 
Upvote 0
Top