SQLiteUtils { public static boolean doesColumnExist(SQLiteDatabase db, String tableName, String columnName) { return getColumnNames(db, tableName).contains(columnName); } private  SQLiteUtils(); static boolean doesTableExist(SQLiteDatabase db, String tableName); static boolean doesColumnExist(SQLiteDatabase db, String tableName, String columnName); static List<String> getColumnNames(SQLiteDatabase db, String tableName); static void addColumn(SQLiteDatabase db, String table, String column, String type); static void renameTable(SQLiteDatabase db, String table, String newTable); static void copyRows(SQLiteDatabase db, String srcTable, String[] columns, String dstTable); static void dropTable(SQLiteDatabase db, String table);  }
@Test public void doesColumnExistTest() { String tableName = "testTable"; SQLiteDatabase db = Collect.getInstance().openOrCreateDatabase("testDatabase", MODE_PRIVATE, null); db.execSQL("CREATE TABLE " + tableName + " (id integer, column1 text);"); assertTrue(SQLiteUtils.doesColumnExist(db, tableName, "id")); assertTrue(SQLiteUtils.doesColumnExist(db, tableName, "column1")); assertFalse(SQLiteUtils.doesColumnExist(db, tableName, "column2")); }