DBFlow listen when query finish

172 Views Asked by At

Hello guys i've read the documentation of DBFlow - ORM android database library , but i was wondering what is the right way to listen when a query finish it's work. For example i've got insert and want to know if the insert is successful and when exactly finish.

DBFlow Library

1

There are 1 best solutions below

0
On BEST ANSWER

You need to use Transactions. and transactions when executed have 2 callbacks. success and error where you can do further processing. For example:

 transaction
    .success(new Transaction.Success() {
       @Override
       public void onSuccess(Transaction transaction) {
          // called post-execution on the UI thread.
       }
   })
   .error(new Transaction.Error() {
       @Override
       public void onError(Transaction transaction, Throwable error) {
          // call if any errors occur in the transaction.
       }
   });

Check following link for more details:

Storing data using DBFlow