I have a button which updates an SQLite database using BeginTransaction and EndTransaction.
This phone is slow and it is easy to click on the button again before the previous transaction is complete.
When doing so, the app crashes:
B4X:
java.lang.IllegalStateException: Cannot perform this operation because the transaction has already been marked successful. The only thing you can do now is call endTransaction().
I could implement locks or use Try/Catch but I wanted to know if there was a more direct way to check if a transaction is in progress?
My first thought was to set a tag on the button when clicked and unset it when the transaction is completed. Check the tag when clicked before performing again.
It has a built in begin/end transaction. After you first click the Button, immediately have: btn.enable =false, then when the transaction is successful and complete. enable the button: btn.enable=true
It has a built in begin/end transaction. After you first click the Button, immediately have: btn.enable =false, then when the transaction is successful and complete. enable the button: btn.enable=true
ProgressDialogShow2 (Text As CharSequence, Cancelable As Boolean)
Shows a dialog with a circular spinning bar and the specified text.
Unlike Msgbox and InputList methods, the code will not block.
You should call ProgressDialogHide to remove the dialog.
Cancelable - Whether the user can dismiss the dialog by pressing on the Back key.
B4X:
ProgressDialogShow2("Determining GPS Location",False)
'getting GPS info
ProgressDialogHide