I'm looking for a way to fill/update my SQLiteDatabase table. On some occasions I need to be notified (by certain return value). Each row contains a url of a file that needs to be downloaded later.
- row does not exist yet: insert it and notify me that this row should be listed for download.
- row does exist but the one I'm trying to insert contains the same values as the one already in the db: do nothing, do not notify me that this should be downloaded.
- row does exist and the one I'm trying to insert contains different values as the one already in the db: replace this row, notify me that this should be downloaded.
I've been looking for the answer but can't seem to find something good. Should I use insertWithOnConflict(), replace(), replaceOrThrow(), ...
Thanks!
triggers...insertWithOnConflict()withCONFLICT_REPLACEas conflict algorithm, combined with a column with aUNIQUEconstraint, but that will only respect the 1st and 3rd cases of the ones you listed. In the 2nd case, it will delete the old row and insert a new one anyway, at least that's how I read the documentation. See link. But even that mentions that its behaviour might change in the future.