I have a database which i am inserting to. Right now I have this code.
database.insertWithOnConflict(FOO_TABLE, null, values,
SQLiteDatabase.CONFLICT_REPLACE);
This inserts into my database. Is there an efficient way to 开发者_StackOverflow中文版see if a row has been updated and not inserted with the constraint CONFILCT_REPLACE? Thanks!
You can compare returned _id with previously retrieved max(_id) - if _id > max(id) record was inserted, otherwise replaced. Other way is a bit dumb - try to insert, in case of sql exception make update.
精彩评论