Android SQL - Check if whole row already exists in database

前端 未结 3 1581
时光取名叫无心
时光取名叫无心 2021-01-18 19:42

I\'m trying to create a simple favorites application, where you can keep your favorites pages (from the web for example).

Let\'s say I have the following data in my

3条回答
  •  青春惊慌失措
    2021-01-18 20:18

    There is a very graceful (imho) way to do this at the database level. Add this to your create table sql when you create your database:

     UNIQUE(TITLE, URL) ON CONFLICT REPLACE 
    

    Then you can insert all you want without checking, it will either be added or updated if the row is already there.

提交回复
热议问题