Okay, so behaviour you're describing is correct:
If DB doesn't exit it runs onCreate
If DB exists - it takes it version and runs onUpdate to the version you specify in constructor.
Apparently it is expected for you to create a newest version of DB in on create method for clean install and have code replicated partially in onUpgrade if user is updating app...
If you're like me and think it's not a nice approach to dublicate code I suggest you doing this:
public const int VERSION = 2;
@Override
public void onCreate(SQLiteDatabase db) {
// create a first version of your DB in this method only
db.execSQL("CREATE TABLE " + TABLE + " ( " + C_ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + C_ENAME + " text, "
+ C_DESIGNATION + " text, " + C_SALARY + " text )");
this.onUpgrade(db, 1, VERSION); // run onUpgrade manually
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Deal with all other versions separatelly
for(int i = oldVersion + 1; i <= newVersion; i++) {
switch(i) {
case 2:
db.execSQL("ALTER TABLE " + TABLE + " ADD COLUMN " + C_TAXES + " text;");
break;
}
}
}
This approach is good if you don't want to lose data. If you don't care for data - then just make newest version of DB in onCreate and in onUpgrade - drop old DB and run onCreate.