public static boolean isColumnExists(String columnName,String tableName,SQLiteDatabase db){
  if (TextUtils.isEmpty(columnName) || TextUtils.isEmpty(tableName)) {
    return false;
  }
  boolean exist=false;
  Cursor cursor=null;
  try {
    String checkingColumnSQL="pragma table_info(" + tableName + ")";
    cursor=db.rawQuery(checkingColumnSQL,null);
    if (cursor.moveToFirst()) {
      do {
        String name=cursor.getString(cursor.getColumnIndexOrThrow("name"));
        if (columnName.equalsIgnoreCase(name)) {
          exist=true;
          break;
        }
      }
 while (cursor.moveToNext());
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    exist=false;
  }
 finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  return exist;
}

public static boolean isColumnExists ( String columnName , String tableName , SQLiteDatabase db ) { if ( TextUtils . isEmpty ( columnName ) || TextUtils . isEmpty ( tableName ) ) { return false ; } boolean exist = false ; Cursor cursor = null ; try { String checkingColumnSQL = "pragma table_info(" + tableName + ")" ; cursor = db . rawQuery ( checkingColumnSQL , null ) ; if ( cursor . moveToFirst ( ) ) { do { String name = cursor . getString ( cursor . getColumnIndexOrThrow ( "name" ) ) ; if ( columnName . equalsIgnoreCase ( name ) ) { exist = true ; break ; } } while ( cursor . moveToNext ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; exist = false ; } finally { if ( cursor != null ) { cursor . close ( ) ; } } return exist ; }
test if a column exists in a table . cases are ignored .
