From ffb49c72177d71f1efaff944a52ca43a1fb63428 Mon Sep 17 00:00:00 2001 From: Dheeraj CVR Date: Wed, 13 Jan 2016 11:55:46 +0400 Subject: [PATCH] use batch transactions when writing roster Fixes https://github.com/siacs/Conversations/issues/1648 --- .../eu/siacs/conversations/persistance/DatabaseBackend.java | 3 +++ 1 file changed, 3 insertions(+) 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); }