SQLite数据库 简单使用

1.添加依赖

implementation'org.litepal.guolindev:core:3.1.1'

2.配置


3.数据库简单操作

1.增加


val dispatchScreenBean = DispatchScreenBeans()

dispatchScreenBean.order_id = v.order_id

dispatchScreenBean.plate_num = v.plate_num

dispatchScreenBean.status = v.status

dispatchScreenBean.save()//增加保存

dispatchScreenBean.update(id)//替换当前第ID条所有数据

2.删除

LitePal.deleteAll(DispatchScreenBeans::class.java, "status > ?", "4")//删除表内所有status >4的数据

LitePal.delete(DispatchScreenBeans::class.java,id)//删除当前第ID条所有数据

3.查询

LitePal.where("status = ?", 1).order("status").find(BusinessScreenBean::class.java)//查询表内所有status==1的数据

LitePal.where("status=?", 1).find()//查询表内所有status==1的数据

你可能感兴趣的:(SQLite数据库 简单使用)