My application uses the remote REST API and populates the local db using greenDao. I have a service with the AsyncTask class:
@Override protected Void doInBackground(Void... params) { insert100RowsIntheFirstTable(); insert100RowsIntheSecondTable(); }
Inside each insert method, I have insertOrReplaceInTx, which I use primarily to increase performance.
I need to discard the results if any of the methods cannot get the data. This must be done through the same transaction.
I wonder if it is correct to surround my calls with the insert method with mDaoSession.callInTx(callable) , having insertOrReplaceInTx inside the methods. I'm right?
In addition, how can I refuse a transaction in case of an exception - is this done automatically with greenDao?
source share