samedi 21 mars 2015

Android-SQLite: How to deal with unique values?

I'm trying to write to a database, in my spec I had to ensure that there are no duplicates for a specific field. Great! I can just make the column unique.


But I have no idea how to deal with that after. If I use the application and accidentally insert a new value which happens to already exist, the app will just crash. How do I check that the value already exists before I try to update the database?


I feel like an if command would work, Buuuuut, How do you scan every value for that column on android anyway?


Aucun commentaire:

Enregistrer un commentaire