使用日期时间类型的房间

时间:2018-11-14 14:44:53

标签: android sqlite android-room

我有一个应用程序,它已经有一个带有列类型的Sqlite数据库: 文字,整数和DATETIME。而且我在房间方面遇到了一些问题,因为我不知道在实体类中为datetime字段使用哪种数据类型。当我尝试进行迁移时,我会得到:

Caused by: java.lang.IllegalStateException: Migration didn't properly handle CALL_INFO_TABLE(callcatcher.call.com.callcatcher.sqlite.CallData).
     Expected:
    TableInfo{name='CALL_INFO_TABLE', columns={date=Column{name='date', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, path=Column{name='path', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, createdDate=Column{name='createdDate', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0}, group_name=Column{name='group_name', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, hint=Column{name='hint', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, name=Column{name='name', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, phone_number=Column{name='phone_number', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}, id=Column{name='id', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=1}, state=Column{name='state', type='TEXT', affinity='2', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}
     Found:
    TableInfo{name='CALL_INFO_TABLE', columns={date=Column{name='date', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, path=Column{name='path', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, createdDate=Column{name='createdDate', type='datetime', affinity='1', notNull=false, primaryKeyPosition=0}, group_name=Column{name='group_name', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, hint=Column{name='hint', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, name=Column{name='name', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, phone_number=Column{name='phone_number', type='text', affinity='2', notNull=false, primaryKeyPosition=0}, id=Column{name='id', type='integer', affinity='3', notNull=false, primaryKeyPosition=1}, state=Column{name='state', type='text', affinity='2', notNull=false, primaryKeyPosition=0}}, foreignKeys=[], indices=[]}

如您所见-列createdDate中存在类型不匹配。我需要将Java类字段映射到datetime列或其他一些解决方法。

0 个答案:

没有答案