I am sorry if this question irritates you. I had been trying to solve for so long. I still could not find the difference between the "Expected" and "Found".
Caused by: java.lang.IllegalStateException: Pre-packaged database has an invalid schema: question(com.bangladroid.drivingtest.database.model.Question).
Expected:
TableInfo{name='question', columns={image=Column{name='image', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, question=Column{name='question', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, answer=Column{name='answer', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, answer3=Column{name='answer3', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, answer2=Column{name='answer2', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, _id=Column{name='_id', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=1, defaultValue='null'}, favorite=Column{name='favorite', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, answer1=Column{name='answer1', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
Found:
TableInfo{name='question', columns={image=Column{name='image', type='integer', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, question=Column{name='question', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, answer=Column{name='answer', type='integer', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, answer3=Column{name='answer3', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, answer2=Column{name='answer2', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, _id=Column{name='_id', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, favorite=Column{name='favorite', type='integer', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, answer1=Column{name='answer1', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
Is there any difference between "integer" and "INTEGER"? what does primaryKeyPosition mean?
Is there any difference between "integer" and "INTEGER"?
No column types are case insensitive.
I still could not find the difference between the "Expected" and "Found".
The difference is that the _id column is defined differently.
primaryKeyPosition=1
(expected) v primaryKeyPosition=0
(found)
So you need to make the pre-packaged database define the _id column to include PRIMARY KEY
. (Room requires that an Entity(table) has a primary key defined so the Entity cannot be changed to suit).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.