alter table add column if not exists sqlite code example
Example: android sqlite add column if not exists
Cursor cursor = database.rawQuery("SELECT * FROM MY_TABLE", null); // grab cursor for all data
int deleteStateColumnIndex = cursor.getColumnIndex("MISSING_COLUMN"); // see if the column is there
if (deleteStateColumnIndex < 0) {
// missing_column not there - add it
database.execSQL("ALTER TABLE MY_TABLE ADD COLUMN MISSING_COLUMN int null;");
}