小编Ale*_*ski的帖子

Android房间迁移空错误

当我在 Android 上从旧的 sqlite 方式迁移到 Room 时,我需要使用“INTEGER NOT NULL”进行编译。问题是,当迁移发生时,您正在使用“NOT NULL”参数在新表中插入 NULL 字段,但出现错误

android.database.sqlite.SQLiteConstraintException:NOT NULL 约束失败:note.notification_state(代码 1299)

编辑:

11-29 22:52:58.891 14605-14630/com.aleksandarvasilevski.notes E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
                                                                            Process: com.aleksandarvasilevski.notes, PID: 14605
                                                                            java.lang.IllegalStateException: Migration didn't properly handle note(com.aleksandarvasilevski.notes.repository.db.Note).
                                                                             Expected:
                                                                            TableInfo{name='note', columns={notification_date=Column{name='notification_date', type='TEXT', notNull=false, primaryKeyPosition=0}, priority=Column{name='priority', type='INTEGER', notNull=true, primaryKeyPosition=0}, description=Column{name='description', type='TEXT', notNull=false, primaryKeyPosition=0}, title=Column{name='title', type='TEXT', notNull=false, primaryKeyPosition=0}, id=Column{name='id', type='INTEGER', notNull=true, primaryKeyPosition=1}, notification_state=Column{name='notification_state', type='INTEGER', notNull=true, primaryKeyPosition=0}, created_date=Column{name='created_date', type='TEXT', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
                                                                             Found:
                                                                            TableInfo{name='note', columns={notification_date=Column{name='notification_date', type='TEXT', notNull=false, primaryKeyPosition=0}, priority=Column{name='priority', type='INTEGER', notNull=false, primaryKeyPosition=0}, title=Column{name='title', type='TEXT', notNull=false, primaryKeyPosition=0}, …
Run Code Online (Sandbox Code Playgroud)

sqlite android android-room android-architecture-components

1
推荐指数
1
解决办法
4660
查看次数