db_version is a value you specify manually. When a database is created, it stores this db_version you set manually for further uses.
Everytime the helper class iniziates it checks if db_version is the same than the one internally stored. If this number is different, then onUpgrade() method is call yo you can perform upgrade operations. Let me put you an example:
- You create an app and with db_version == 1.
- You develop a new
functionality wich introduces changes in the database (for example,
a new column). You will change db_version to 2. In the onUpgrade()
method, you will add the new column to all existing rows.
- When you intall the new version of your app in the device, when you first
open your db, the version it is checked. Your database has version 1
but db_version is 2 now, so onUpgrade() is called and the new column
added.
And that is the use.