I searched in topics and I had not found any questions related to my problem, so this is why I opened this thread. It is not easy to explain but I will try.
So I have a database and I have two queries to update and to get a value for a specific column. (By the way the value for this column is 0 by default.) I control these two methods with a ToggleButton, so when togglebutton.isChecked() is set to true I call the update query and I put the current time into the datatable specific column. It is working well. When I click on ToggleButton again and toggleButton.isChecked() is set to false I call a select query to get this value. It is working. Okay.
if (toggleButton.isChecked()) {
databaseHelper.updateStart(id, (int) new Date().getTime() / 1000);
} else {
Integer startTime = databaseHelper.getStart(id);
}
So my problem comes in a scenario.
When I click too quickly two times on the ToggleButton then I sometimes get the value 0 and not the currently saved seconds. If I click slowly then database has the time to update the entry and when I click again after it, it will query the good value. But in case when user clicks too fast sometimes it returns the value 0. I think the problem is when user clicks too fast in the ToggleButton sometimes the getStart() method is called sooner than updateStart is finished and then 0 will be returned. My question is how can I solve that database dont call any other query while previous is not closed or finished, or how to make it work.
Thanks in advance,
Aucun commentaire:
Enregistrer un commentaire