barcodereader
barcodereader

Reputation: 2038

Android SQLite Optimization adding rows

I am adding about 3000 rows to SQLite database and it takes about 8 seconds. How can I optimize this.

Upvotes: 0

Views: 1262

Answers (2)

Graham Borland
Graham Borland

Reputation: 60681

If you aren't already, wrap the entire operation in a transaction. Your code should look something like this:

db.beginTransaction();
try {
    // insert your data here
    db.setTransactionSuccessful();
} finally {
    db.endTransaction();
}

Upvotes: 3

Ted Hopp
Ted Hopp

Reputation: 234807

Try executing PRAGMA synchronous = OFF before doing the updates.

Upvotes: 1

Related Questions