pushtorefresh / storio

Reactive API for SQLiteDatabase and ContentResolver.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete all objects and put in one operation with only one notification of observables

Verichev opened this issue · comments

I would like just to replace all content of a table with new content. To do this I use two operations "delete" and then "update". But my subscribed observables receive two notifications in this case. How can I avoid notification after deleting table content or is there any all-in-one operation for replacting all content in a table?

You can do it in a transaction:

storIOSQLite.lowLevel().beginTransaction()

try {
  // perform operations here
  storIOSQLite.lowLevel().setTransactionSuccessful()
} finally {
  storIOSQLite.lowLevel().endTransaction()
}

Please do it off the main thread!