public static void addMissingColumns ( SQLiteDatabase database , Class contractClass ) { Contract contract = new Contract ( contractClass ) ; Cursor cursor = database . rawQuery ( "PRAGMA table_info(" + contract . getTable ( ) + ")" , null ) ; for ( ContractField field : contract . getFields ( ) ) { if ( ! fieldExistAsColumn ( field . name , cursor ) ) { database . execSQL ( "ALTER TABLE " + contract . getTable ( ) + " ADD COLUMN " + field . name + " " + field . type + ";" ) ; } } }
Adds missing table columns for the given contract class .