Checking for duplicates android sql using multiple columns
Jason C Williams
posted 2 years ago
I have an app that scans a bar code and enters the info in to a db in my app. What I need it to do is check the db for the information when the bar code is scanned, and then either write the info to the db or show a toast letting the user know that the bar code has already been scanned for this event, on this date, for this user and can not be entered in the db again. There are three columns that I need it to query against, date, event, and empID. I have gotten to where it will alert when a duplicate is found, but it is still writing to the db and the toast is staying on the screen a lot longer than it should. I have tried to add break; in the if statement after the toast and after where it is writing to the db, but it caused it to write to the db multiple times for some reason. This is my first attempt with android db and I am still new to SQLite as well, so any help someone can offer is greatly appreciated.
Here is the public cursor from my db helper class if needed.