diff options
author | Dheeraj CVR <cvr.dheeraj@gmail.com> | 2016-01-13 11:55:46 +0400 |
---|---|---|
committer | Dheeraj CVR <cvr.dheeraj@gmail.com> | 2016-01-13 11:56:35 +0400 |
commit | ffb49c72177d71f1efaff944a52ca43a1fb63428 (patch) | |
tree | d869a1796258af6727b44ece4750aaba23690f64 /src/main/java/eu/siacs | |
parent | 3e9fd0185a792b349ce2f8b9e8b6a5967c16fee0 (diff) |
use batch transactions when writing roster
Fixes https://github.com/siacs/Conversations/issues/1648
Diffstat (limited to 'src/main/java/eu/siacs')
-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); } |