I write app on android which will use android SQLite database. I have table which will contain data rows with unique Id. From time to time I need to add new row or update old row. For now I when I want to add/update data I must check if I have row with specified Id in table. If I have I update suitable row. If I dont I create new row with new unique key. My question is: is there something in Android what can automagically check if in database is row with specified id and then just update it and if there isnt such row add new?
Share
Check out the SQLite documentation for the insert statement. You can use a
insert or replacestatement (or justreplace, which is a shortcut).You use it just like you would a traditional
insertstatement. This is probably useful in your case since you already have the key known.