I used this example to create a database that I copied on a new installation
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Problem: now I have done some database updates, and I figured that I also do this update for the main file in the assembly so that users always get the latest version of the new installation
I have another class that handles all db request request requests.
I set this line
private static final int DATABASE_VERSION = 5;
On a new installation, the database is now copied correctly, but when the query class calls the databasehelper method again, the onupgrade () method is called and tries to upgrade to the latest version, and the application crashes when it tries to perform updates that cannot be performed
I was in the understanding that the following sets the version of the database on fresh installations or it is wrong. If so, how can I install the database version for new installations
public DatabaseHelper(Context context) { super(context, DB_NAME, null, DATABASE_VERSION); this.context = context; }
just for completeness, there is an onupgrade () sample here
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { dbUpgrade = new DatabaseUpgrades(context); Log.d(DEBUG_TAG, "Calling onupgrade db"); Log.d(DEBUG_TAG + " : " + DatabaseHelper.class.getName(), "Upgrading database from version " + oldVersion + " to " + newVersion); if (oldVersion == 1) { Log.d(DEBUG_TAG, "Updating to Version 2"); dbUpgrade.upgradeDB2(db); oldVersion++; } }
Question: which version is the new database installed for the new installation, and how can it be rewritten if it is not version 5
thanks