greenDao
读取data/data/包名下的数据库文件
image.png
image.png
报错如下:
android.database.sqlite.SQLiteException: no such table: SECU_ALARM_RECORD (code 1): , while compiling: INSERT INTO "SECU_ALARM_RECORD" ("_id","ZONE_NO","ALARM_TYPE","TOUCH_TYPE","READ_FLAG","ALARM_TIME") VALUES (?,?,?,?,?,?)
greenDao自动生成表的时候会根据名称的大小写添加'_',如果数据库文件恰好没按规范命名来就gg了
修复如下:
1.找不到表 ,添加nameInDb 属性,这样表名就不会变成SECU_ALARM_RECORD
@Entity(nameInDb = "secuAlarmRecord")
public class SecuAlarmRecord {
2.属性找不到
全部换成小写
@Entity(nameInDb = "secuAlarmRecord")
public class SecuAlarmRecord {
@Id
private Long id;
public int zoneno;
public int alarmtype;
public int touchtype;
public int readflag;
public String alarmtime;
}
网友评论