private void createIntermediateTable(String tableName,String associatedTableName,SQLiteDatabase db,boolean force){
  List<ColumnModel> columnModelList=new ArrayList<ColumnModel>();
  ColumnModel column1=new ColumnModel();
  column1.setColumnName(tableName + "_id");
  column1.setColumnType("integer");
  ColumnModel column2=new ColumnModel();
  column2.setColumnName(associatedTableName + "_id");
  column2.setColumnType("integer");
  columnModelList.add(column1);
  columnModelList.add(column2);
  String intermediateTableName=DBUtility.getIntermediateTableName(tableName,associatedTableName);
  List<String> sqls=new ArrayList<String>();
  if (DBUtility.isTableExists(intermediateTableName,db)) {
    if (force) {
      sqls.add(generateDropTableSQL(intermediateTableName));
      sqls.add(generateCreateTableSQL(intermediateTableName,columnModelList,false));
    }
  }
 else {
    sqls.add(generateCreateTableSQL(intermediateTableName,columnModelList,false));
  }
  execute(sqls.toArray(new String[0]),db);
  giveTableSchemaACopy(intermediateTableName,Const.TableSchema.INTERMEDIATE_JOIN_TABLE,db);
}

private void createIntermediateTable ( String tableName , String associatedTableName , SQLiteDatabase db , boolean force ) { List < ColumnModel > columnModelList = new ArrayList < ColumnModel > ( ) ; ColumnModel column1 = new ColumnModel ( ) ; column1 . setColumnName ( tableName + "_id" ) ; column1 . setColumnType ( "integer" ) ; ColumnModel column2 = new ColumnModel ( ) ; column2 . setColumnName ( associatedTableName + "_id" ) ; column2 . setColumnType ( "integer" ) ; columnModelList . add ( column1 ) ; columnModelList . add ( column2 ) ; String intermediateTableName = DBUtility . getIntermediateTableName ( tableName , associatedTableName ) ; List < String > sqls = new ArrayList < String > ( ) ; if ( DBUtility . isTableExists ( intermediateTableName , db ) ) { if ( force ) { sqls . add ( generateDropTableSQL ( intermediateTableName ) ) ; sqls . add ( generateCreateTableSQL ( intermediateTableName , columnModelList , false ) ) ; } } else { sqls . add ( generateCreateTableSQL ( intermediateTableName , columnModelList , false ) ) ; } execute ( sqls . toArray ( new String [ 0 ] ) , db ) ; giveTableSchemaACopy ( intermediateTableName , Const . TableSchema . INTERMEDIATE_JOIN_TABLE , db ) ; }
when it comes to many2many associations . database need to create an intermediate table for mapping this association . this method helps create such a table , and the table name follows the concatenation of the two target table names in alphabetical order with underline in the middle .
