diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-01-13 10:56:29 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-01-13 10:56:29 +0100 |
commit | 5f63c397fa7e6790e4a94bd3ae193af23946c7c9 (patch) | |
tree | d869a1796258af6727b44ece4750aaba23690f64 | |
parent | 3e9fd0185a792b349ce2f8b9e8b6a5967c16fee0 (diff) | |
parent | ffb49c72177d71f1efaff944a52ca43a1fb63428 (diff) |
Merge pull request #1649 from dhiru1602/master
use batch transactions when writing roster
-rw-r--r-- | src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 3077c4889..c73a05647 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -577,6 +577,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public void writeRoster(final Roster roster) { final Account account = roster.getAccount(); final SQLiteDatabase db = this.getWritableDatabase(); + db.beginTransaction(); for (Contact contact : roster.getContacts()) { if (contact.getOption(Contact.Options.IN_ROSTER)) { db.insert(Contact.TABLENAME, null, contact.getContentValues()); @@ -586,6 +587,8 @@ public class DatabaseBackend extends SQLiteOpenHelper { db.delete(Contact.TABLENAME, where, whereArgs); } } + db.setTransactionSuccessful(); + db.endTransaction(); account.setRosterVersion(roster.getVersion()); updateAccount(account); } |