http://www.outofwhatbox.com/blog/2010/12/android-using-databaseutils-inserthelper-for-faster-insertions-into-sqlite-database/
This is a good article.
two ways to do batch insert:
try{
db.beginTransaction();
for each record in the list {
do_some_processing();
if (line represent a valid entry) {
db.insert(SOME_TABLE, null, SOME_VALUE);
}
some_other_processing();
}
db.setTransactionSuccessful();
} catch (SQLException e) {
} finally {
db.endTranscation();
}
try {
mDb.beginTransaction();
InsertHelper ih = new InsertHelper(db, "columnTable");
for (Value value : values) {
ih.prepareForInsert();
ih.bind(colIdx, value.getSomeValue());
// ...
ih.execute();
}
mDb.setTransactionSuccessful();
} finally {
mDb.endTransaction();
}
The second one is really helpful,because i want to insert the records with the field index and without knowing the field name .