I've spent quite some time reading what I can find about the often confusing and often dreaded SQLite Databse Version Number. I've found out that it is apparently stored in the Database header file 60bytes in as per:- Where does Android store SQLite's database version?
I've gone to quite some lengths to get around it. Created classes (DBDatabase
, DBtable
and DBColumn
) and quite a few methods that allow me to basically have an awayfrom-the-database schema.
One of the cumulative methods actionDBAlterSQL
compares the SQLite schema via PRAGMA for all tables and columns and will then run generated ALTER
statements to ADD
any columns that have been added.
To invoke this I've added an onExpand
method in the DBHelper
and thus get around version control.
I'm still testing things, but it certainly works in principle. I've added and columns just by making a few changes in a single block of code specifically for the purpose of relatively easily managing the schema/design (and if things go that way other projects that I am involved with).
However, I can find very little about the actual scope of the Database Version number other than that an increase to the version results (when done correctly) onUpgrade
being invoked.
My main interest revolves around the question; Am I going to end up breaking anything by circumventing using the version number?
I'd also like to know if I'm missing out on any useful features; perhaps rollback to a previous version of the schema or even data (I've not seen anything related so I suspect that isn't the case).
Is it perhaps just a convenience, as such, and basically just a number that if increased allows onUpgrade
to run? It's the suspicion that this is the case that diverted me along this path :).
Additionally the subject of how to successfully work with the version number appears to be quite a frequent question, as such perhaps any findings here could be of assistance to others.