加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Sqlite 之update

发布时间:2020-12-12 20:28:50 所属栏目:百科 来源:网络整理
导读:update(String table,ContentValues values,String whereClause,String[] whereArgs) Convenience method for updating rows in the database.//方便的方法更新数据库中的行 table 数据库的表名 values 用来更新数据的ContentValue 的对象 whereClause 用来
update(String table,ContentValues values,String whereClause,String[] whereArgs) Convenience method for updating rows in the database.//方便的方法更新数据库中的行 table 数据库的表名 values 用来更新数据的ContentValue 的对象 whereClause 用来指定更新的行,一般为 “_id = ?” ,若为null,所有的行均被更新 whereArgs where 语句中表达式的?占位参数列表,参数只能为String类型,当为1时,用new String[]{Integer.toString(1)},表示_id = 1 的那行改变数据 一、 SQLiteDatabase db = getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(IDCODE,id); cv.put(NAME,name); cv.put(SEX,sex); int flag = db.update(T_NAME,cv,ID + " = ? ", new String[] { Integer.toString(_id) }); //更新成功返回1,否则返回0; 二、 sql 语句: db.execSQL("update " + T_NAME + " set s_id=?,s_name=?,s_sex=? where _id=?",new Object[] { id,name,sex,Integer.toString(_id) });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读