2018-05-02

greenDao
读取data/data/包名下的数据库文件


2018-05-02_第1张图片
image.png

2018-05-02_第2张图片
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;
}

你可能感兴趣的:(2018-05-02)