[英]Update database (SQLiteDatabase issue)
everyone. 大家。 This is a piece of code from using sqlite in android tutorial:
这是在Android教程中使用sqlite的一段代码:
return db.update(employeeTable, cv, colID+"=?",
new String []{String.valueOf(emp.getID())});
I don't understand why in colID+"=?"
我不明白为什么在
colID+"=?"
after '=' stay '?' 在'='停留'之后?
Anyone can explain this, please? 有人可以解释吗?
Thanks for everyone! 谢谢大家!
This is parametrized statement, this mean that this String.valueOf(emp.getID())
will be added intead of ?
这是参数化的语句,这意味着
String.valueOf(emp.getID())
添加到?
character. 字符。
?
represents one argument and String[]
represents data which will be added to where
clause. 表示一个参数,而
String[]
表示将添加到where
子句的数据。
The ?
?
is where your argument is substituted into the query. 是您的参数被替换为查询的位置。 Your argument in this case is
String.valueOf(emp.getID()
. 在这种情况下,您的参数是
String.valueOf(emp.getID()
。
This is a Prepared Satatement. 这是预备的状态。 In this case, you can define a query as a template and left some parameters to fill dynamically.
在这种情况下,您可以将查询定义为模板,并保留一些参数以进行动态填充。 You represent the parameter with an
?
您用
?
表示参数?
. 。 In your case, you are indicating that
String.valueOf(emp.getID())
will substitute the ?
在您的情况下,您表示
String.valueOf(emp.getID())
将替代?
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.