Unique constraint failed room database android

后端 未结 2 1932
刺人心
刺人心 2020-12-19 07:22

I\'m facing a problem with Room database, when trying to use insert method that I declared in Dao Class to write a data into database this error shows up:

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 08:05

    I figure it out, that error because there is no unique value in data (in primaryKey) so I make it auto generated,

    Model Class

    @Entity
    public class Task {
        @PrimaryKey(autoGenerate = true)
        private int uid;
        ...
    }
    

提交回复
热议问题