记录一下SQLite批量操作的写法
try {
SQLiteDatabase db = DBHelper.getDatabase();
String sql = "INSERT INTO " + TABLE + "(col_1, col_2, col_3)VALUES(?,?,?)";
SQLiteStatement statement = db.compileStatement(sql);
db.beginTransaction();
for (Object item : items) {
statement.bindString(1, item.val_1);
statement.bindString(2, item.val_2);
statement.bindString(3, item.val_3);
statement.executeInsert();
}
db.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endTransaction();
}