Change SQLite Database Version Number

I have a database that I created in SQLite browser and it works fine. I started the application with a pre-created database, and now I want to add more tables and data to this database.

I can get the application to run the onUpgrade method for SQLiteOpenHelper. But the problem is that I do it EVERY time when I use the assistant.

I have localization, only when the application starts, splitting the update command from the assistant that I used to extract the data, but this is still a problem.

I figured this out because, since I used the same database on my computer (the one I’m editing), starting from version 1. Thus, whenever it writes a new database to the SD card, it shows the version 1 although I'm already up to version 4.

So my question is, how can I manually change the database version of the source database so that when it is updated it does not write the old version number on top of the new one?

+33
android sqlite version
Nov 06 2018-11-11T00:
source share
3 answers

To manually upgrade to version 4, run the following SQL statement:

PRAGMA user_version = 4 
+59
Nov 06 2018-11-11T00:
source share

You can also set it using the setVersion SqlLiteDatabase method.

Source: http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#setVersion(int)

+6
Mar 17 '14 at 21:36
source share

Another way to change the version of your Sqlite database. You can use DB Browser for SQLite:

  • Open the database file using "DB Browser for SQLite".
  • Change the "Custom Version" number to whatever number you want.
  • Click "Save" Sqlite database browser
+1
Jul 10 '17 at 0:13
source share



All Articles