Android:android.database.sqlite.SQLiteConstraintException:UNIQUE constraint failed

可能发生这种BUG的两种情况 
1:定义的字段为NOT NULL,而插入时对应的字段为NULL 
2:你定义的自动为PRIMARY,而插入时想插入的值已经在表中存在。

针对情况2,greendao建议用insertOrReplace代替insert 

猜你喜欢

转载自blog.csdn.net/songzi1228/article/details/81456612