Merge pull request #1649 from dhiru1602/master
use batch transactions when writing roster
This commit is contained in:
commit
5f63c397fa
|
@ -577,6 +577,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
public void writeRoster(final Roster roster) {
|
public void writeRoster(final Roster roster) {
|
||||||
final Account account = roster.getAccount();
|
final Account account = roster.getAccount();
|
||||||
final SQLiteDatabase db = this.getWritableDatabase();
|
final SQLiteDatabase db = this.getWritableDatabase();
|
||||||
|
db.beginTransaction();
|
||||||
for (Contact contact : roster.getContacts()) {
|
for (Contact contact : roster.getContacts()) {
|
||||||
if (contact.getOption(Contact.Options.IN_ROSTER)) {
|
if (contact.getOption(Contact.Options.IN_ROSTER)) {
|
||||||
db.insert(Contact.TABLENAME, null, contact.getContentValues());
|
db.insert(Contact.TABLENAME, null, contact.getContentValues());
|
||||||
|
@ -586,6 +587,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
db.delete(Contact.TABLENAME, where, whereArgs);
|
db.delete(Contact.TABLENAME, where, whereArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
db.endTransaction();
|
||||||
account.setRosterVersion(roster.getVersion());
|
account.setRosterVersion(roster.getVersion());
|
||||||
updateAccount(account);
|
updateAccount(account);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue