Answers for "android sqlite add column if not exists"

SQL
0

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;");
}
Posted by: Guest on November-05-2020

Code answers related to "android sqlite add column if not exists"

Code answers related to "SQL"

Browse Popular Code Answers by Language