GreenDao使用注意事项

1,415 阅读1分钟
  • 如果新版本中新增加了表,需要修改greendao配置中schemaVersion,让其加1即可
greendao {
    schemaVersion, 2
    daoPackage 'com.xx.xx.storage.db.base'
    targetGenDir 'src/main/java'
}

否则出现如下错误

android.database.sqlite.SQLiteException: no such column:
  • greendao中model的定义id时,如果id不是String,那么id必须定义为long,不能为int
@Id
@Unique
public long id;