1

So I got a sqlite database (version 7) which stores data for my App (version 1.0) and I want to fix a few bugs (that have nothing to do with my database). What happens if I update my App to version 1.1? will the data be deleted? or will it just be deleted if i update the databse version to 8?

(My onUpgrade in the databasehandler will delete the existing databse and create a new one by the way)

ninety
  • 43
  • 9

2 Answers2

2

Upgrading an app does not do anything to the database. Old data files are kept intact.

Changing the version number in code for your SQLiteOpenHelper will cause onUpgrade() to be called if the version number in the database file is lower. That by itself doesn't delete anything, but if you yourself delete the data (as you say), then it is lost.

See also: When is SQLiteOpenHelper onCreate() / onUpgrade() run?

Community
  • 1
  • 1
laalto
  • 150,114
  • 66
  • 286
  • 303
0

Data will delete if you change the version, but in onUpgrade method we have two parameters

called oldVersion and newVersion. we can do what ever we want by checking old new version

condition.

GangaNaidu
  • 194
  • 6