【发布时间】:2018-10-06 17:00:26
【问题描述】:
我正在使用 Room。 我有这个插入方法:
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insert(Month month);
我的插入方法:
for(...){
...
monthDao.insert(new Month(0, monthTitle, monthUrl));
}
也是我的模特
@Entity(tableName = "news_month_table", indices = @Index(value = {"month_index"}, unique = true))
public class Month {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "month_id")
@Getter @Setter
public long month_id;
@ColumnInfo(name = "month_name")
@Getter @Setter
public String monthName;
@ColumnInfo(name = "month_url")
@Getter @Setter
public String monthURL;
@ColumnInfo(name = "month_index")
@Getter @Setter
public int monthIndex;
我的情况: 1)启动应用并下载+插入数据(12轮for()) 现在 base 是正确的,包含 12 行 1-12 个 id。 2)我有新数据(例如一行)。启动应用程序并下载+插入数据。 现在 base 包含 13 行,1-12 和 24 id。
我不知道是什么问题,请帮帮我
【问题讨论】:
标签: android sqlite sequence android-room