Better HN
topnewbestaskshowjobs
Log inSign up

AmelnCam

0 karma · joined Sep 30, 2014 (12y ago) · 1 submissions

Submissions

comment 12y ago · link · parent

I usually use the following code for this purpose: public void testBatchInserts() throws PerformanceTestException { SQLiteStatement stmt = db.compileStatement("INSERT INTO " + EmployeeDatabaseHelper.TABLE_EMPLOYEES + " VALUES(?1, ?2, ?3, ?4)");

        db.beginTransaction();
        for (int row = 0; row < getNumInserts(); row++) {
            stmt.clearBindings();
            stmt.bindString(2, getEmployeeName(row));
            stmt.bindLong(3, getEmployeeAge(row));
            stmt.bindLong(4, getEmployeeHiredStatus(row));
            stmt.executeInsert();
        }
        db.setTransactionSuccessful();
        db.endTransaction();