Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更新方法不适用于';t使用值更新数据库_Android_Sql - Fatal编程技术网

Android 更新方法不适用于';t使用值更新数据库

Android 更新方法不适用于';t使用值更新数据库,android,sql,Android,Sql,下面是我的一段代码,它运行时没有错误,但不会更新数据库: ContentValues cv_lio = new ContentValues(); cv_lio.put("u_lio",1); String where = "u_name" + "=" + 5; db.update(table_name, cv_lio,where,null); 任何人都可以改进我的更新查询以使其正常工作 按以下步骤进行: ContentValues cv_lio = new ContentValues(); c

下面是我的一段代码,它运行时没有错误,但不会更新数据库:

ContentValues cv_lio = new ContentValues();
cv_lio.put("u_lio",1);
String where = "u_name" + "=" + 5;
db.update(table_name, cv_lio,where,null);
任何人都可以改进我的更新查询以使其正常工作

按以下步骤进行:

ContentValues cv_lio = new ContentValues();
cv_lio.put("u_lio",1);
String where = "u_name" + " = ?";
String[] whereArgs = new String[] {String.valueOf(5)};
db.update(table_name, cv_lio, where, whereArgs);

请参考,我必须承认,在这一点上不太清楚…

错误在where子句更正代码




当您希望显示如上所示的字段值时,请查找引号。

@ThinkStip CREATE_TABLE_REGISTER=“如果不存在,请创建表格”+表格名称+“(u_id整数主键自动递增,u_名称文本,u_pwd文本,u_eadd文本,u_padd文本,u_lio整数)”;
ContentValues cv_lio = new ContentValues();
cv_lio.put("u_lio",1);
String where = "u_name='" + un + "'";
db.update(table_name, cv_lio,where,null);