Reputation: 17
I am using Sq Lite database in my android application. I created helper class to create tables in Sq Lite. In helper class i used DB_VERSION attribute and I used DB_VERSION to call super class(SQLiteOpenHelper) constructor. Can anyone tell me what is the use of DB_VERSION attribute in db helper class.
Thank you.
Upvotes: 0
Views: 760
Reputation: 2634
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:
And that is the use.
Upvotes: 1