public static boolean isIntermediateTable(String tableName,SQLiteDatabase db){
  if (!TextUtils.isEmpty(tableName)) {
    if (tableName.matches("[0-9a-zA-Z]+_[0-9a-zA-Z]+")) {
      Cursor cursor=null;
      try {
        cursor=db.query(Const.TableSchema.TABLE_NAME,null,null,null,null,null,null);
        if (cursor.moveToFirst()) {
          do {
            String tableNameDB=cursor.getString(cursor.getColumnIndexOrThrow(Const.TableSchema.COLUMN_NAME));
            if (tableName.equalsIgnoreCase(tableNameDB)) {
              int tableType=cursor.getInt(cursor.getColumnIndexOrThrow(Const.TableSchema.COLUMN_TYPE));
              if (tableType == Const.TableSchema.INTERMEDIATE_JOIN_TABLE) {
                return true;
              }
              break;
            }
          }
 while (cursor.moveToNext());
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
 finally {
        if (cursor != null) {
          cursor.close();
        }
      }
    }
  }
  return false;
}

public static boolean isIntermediateTable ( String tableName , SQLiteDatabase db ) { if ( ! TextUtils . isEmpty ( tableName ) ) { if ( tableName . matches ( "[0-9a-zA-Z]+_[0-9a-zA-Z]+" ) ) { Cursor cursor = null ; try { cursor = db . query ( Const . TableSchema . TABLE_NAME , null , null , null , null , null , null ) ; if ( cursor . moveToFirst ( ) ) { do { String tableNameDB = cursor . getString ( cursor . getColumnIndexOrThrow ( Const . TableSchema . COLUMN_NAME ) ) ; if ( tableName . equalsIgnoreCase ( tableNameDB ) ) { int tableType = cursor . getInt ( cursor . getColumnIndexOrThrow ( Const . TableSchema . COLUMN_TYPE ) ) ; if ( tableType == Const . TableSchema . INTERMEDIATE_JOIN_TABLE ) { return true ; } break ; } } while ( cursor . moveToNext ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { if ( cursor != null ) { cursor . close ( ) ; } } } } return false ; }
judge the table name is an intermediate table or not .
