Sqlite 之update

前端之家收集整理的这篇文章主要介绍了Sqlite 之update前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_403_0@ update(String table,ContentValues values,String whereClause,String[] whereArgs)
@H_403_0@ Convenience method for updating rows in the database.//方便的方法更新数据库中的行
@H_403_0@
@H_403_0@ table 数据库的表名
@H_403_0@ values 用来更新数据的ContentValue 的对象
@H_403_0@ whereClause 用来指定更新的行,一般为 “_id = ?” ,若为null,所有的行均被更新
@H_403_0@ whereArgs where 语句中表达式的?占位参数列表,参数只能为String类型,当为1时,用new
@H_403_0@ String[]{Integer.toString(1)},表示_id = 1 的那行改变数据 @H_403_0@ 一、 @H_403_0@ sqliteDatabase db = getWritableDatabase(); @H_403_0@ ContentValues cv = new ContentValues(); @H_403_0@ cv.put(IDCODE,id); @H_403_0@ cv.put(NAME,name); @H_403_0@ cv.put(SEX,sex); @H_403_0@ int flag = db.update(T_NAME,cv,ID + " = ? ", @H_403_0@ new String[] { Integer.toString(_id) }); //更新成功返回1,否则返回0; @H_403_0@ 二、 @H_403_0@ sql 语句: @H_403_0@ db.execsql("update " + T_NAME @H_403_0@ + " set s_id=?,s_name=?,s_sex=? where _id=?",new Object[] { @H_403_0@ id,name,sex,Integer.toString(_id) });

猜你在找的Sqlite相关文章