????3?????InsertHelper??
???????????API 17?????????????

 

InsertHelper ih = new InsertHelper(db?? "bus_line_station");
db.beginTransaction();
final int directColumnIndex = ih.getColumnIndex("direct");
final int lineNameColumnIndex = ih.getColumnIndex("line_name");
final int snoColumnIndex = ih.getColumnIndex("sno");
final int stationNameColumnIndex = ih.getColumnIndex("station_name");
try {
for (Station s : busLines) {
ih.prepareForInsert();
ih.bind(directColumnIndex?? s.direct);
ih.bind(lineNameColumnIndex?? s.lineName);
ih.bind(snoColumnIndex?? s.sno);
ih.bind(stationNameColumnIndex?? s.stationName);
ih.execute();
}
db.setTransactionSuccessful();
} finally {
ih.close();
db.endTransaction();
db.close();
}

????4?????SQLiteStatement
??????InsertHelper??????????????????????????????SQLiteStatement

 

String sql = "insert into bus_line_station(direct??line_name??sno??station_name) values(??????????)";
SQLiteStatement stat = db.compileStatement(sql);
db.beginTransaction();
for (Station line : busLines) {
stat.bindLong(1?? line.direct);
stat.bindString(2?? line.lineName);
stat.bindLong(3?? line.sno);
stat.bindString(4?? line.stationName);
stat.executeInsert();
}
db.setTransactionSuccessful();
db.endTransaction();
db.close();

?????????????4?з?????????????1????????????????

?????????????????????????????????????????API17?з??????????????????????????????