Reputation: 1711
Obviously my question is about DIRECT UPDATE and not uninstall old version then install new version. There is nothing about it discussed on StackOverflow so I'm asking it to you all because I don't know what does Android do when performing updates.
If the answer is "yes, your db will be deleted and then recreated", then how can I NOT make this happen during an update?
Thank you
Upvotes: 0
Views: 45
Reputation: 36035
Your database will not be deleted by default. Although a very common example that people seem to follow for their SQLiteDatabaseHelper
is this:
void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) {
// DROP TABLES
}
Now when you create a new SQLiteDatabaseHelper
and you pass in a versionNumber
that's higher than the previous one, onUpgrade
will be called and the tables will be dropped. This will not happen at all if the versions are the same. Likewise, the same will happen with onDowngrade
if the version number is lower.
Upvotes: 1