1

Droidparts library has helper-method for execute serial statements in one transaction:

executeStatements(SQLiteDatabase db, ArrayList<String> statements)

But in real life some intermediate inspection can be occur such as:

if(some_check = some_result) { do statement_1 }
else { do statement_2 }

How one can do in these cases?

Valery Kulikov
  • 319
  • 1
  • 12

1 Answers1

1

Well, I got it. One should do it in this manner:

  1. Create Callable task
  2. Put it in PersistUtils.executeInTransaction(SQLiteDatabase db, Callable task)

Pseudocode:

/* Create Callable task */
Callable<Boolean> task = new Callable<Boolean>() {
    @Override
    public Boolean call() throws Exception {

        ... Some operations ...

        return Boolean.TRUE (or FALSE);
    }
};
/* Check result */
Boolean result = PersistUtils.executeInTransaction(getDB(), task);
Valery Kulikov
  • 319
  • 1
  • 12