数据库操作

创建表

public static final String STEPTABLE = "create table if not exists step_info(_id INTEGER PRIMARY KEY,day TEXT ,date TEXT, startStep INTEGER)";
db.execSQL(STEPTABLE);

表里面插入元素

db.execSQL("alter table step_info add startStep INTEGER ");

插入数据

String insertStepSql = "insert into step_info(day,date,startStep)values(?,?,?)";
db.execSQL(insertStepSql, new Object[] { item.day,item.date, item.startStep });

更新数据

String updateStepSql = String.format("update step_info set day='%s',date='%s',startStep='%s' where day='%s'", item.day,item.date, item.startStep,item.day);
db.execSQL(updateStepSql);

查询数据

String selectStepSql = String.format("select * from step_info where day='%s'", item.day);
Cursor cursor=db.rawQuery(selectStepSql, null);
    原文作者:奔跑的图腾
    原文地址: https://www.jianshu.com/p/fb23d760041d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞