aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDheeraj CVR <cvr.dheeraj@gmail.com>2016-01-13 11:55:46 +0400
committerDheeraj CVR <cvr.dheeraj@gmail.com>2016-01-13 11:56:35 +0400
commitffb49c72177d71f1efaff944a52ca43a1fb63428 (patch)
treed869a1796258af6727b44ece4750aaba23690f64 /src/main/java
parent3e9fd0185a792b349ce2f8b9e8b6a5967c16fee0 (diff)
use batch transactions when writing roster
Fixes https://github.com/siacs/Conversations/issues/1648
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java3
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 3077c488..c73a0564 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);
}