I have a database that I want to add a column to, I changed the static database version but when I run the program on my device the new column is still not there so I am guessing my onUpdate
is not getting called and I am not sure why.
this is how I create the database
private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
createTables(db);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion)
{
Log.w("CalendarDB", "Upgrading database from version " + oldVersion
+ " to "
+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS Events_Table");
onCreate(db);
}
private void createTables(SQLiteDatabase db){
db.execSQL("CREATE TABLE " + EVENTS_TABLE + "(" + ID + " integer primary key autoincrement, " +
EVENT + " TEXT, " + LOCATION + " TEXT, " + DESCRIPTION + " TEXT, " + DATE + " TEXT, " + START + " LONG, " + END + " TEXT, " + REAL_START_TIME + " TEXT,"
+ REAL_END_TIME + " TEXT," + COLOR + " TEXT, " + BLINK + " TEXT, " + VIBRATE + " TEXT, " + RING_TONE_PATH + " TEXT, " + ICON + " TEXT, " + REMINDERS +
" TEXT, " + START_WITH_REMINDER + " TEXT, " + CALENDAR_ID + " TEXT, " + EVENT_ID + " TEXT);");
}
}
is there something else I have to do to get the onUpdate
to get called? I tried following this answer but still no result