Java 字符串与 BaseColumns._ID 连接会带来错误
在 Eclipse 中,当我输入以下内容时:
BaseColumns._ID, + "=?"
我得到:
The operator + is undefined for the argument type(s) String
这怎么可能,它们都是字符串,不是吗?
现在这里是 BaseColumns._ID 的文档:
public static final String _ID
我正在编写的代码是:
public void deteleProfile(Long id) throws SQLException {
SQLiteDatabase db = helper.getWritableDatabase();
Integer i = db.delete(ProlificDatabase.TABLE, BaseColumns._ID, + "=?", new String[] {id.toString()});
Log.d(TAG, i + " records deleted where id is " + id);
In eclipse as soon as i type this out:
BaseColumns._ID, + "=?"
I get:
The operator + is undefined for the argument type(s) String
How is that possible, they are both Strings aren't they?
now here is documentation for BaseColumns._ID:
public static final String _ID
the code I am writing is:
public void deteleProfile(Long id) throws SQLException {
SQLiteDatabase db = helper.getWritableDatabase();
Integer i = db.delete(ProlificDatabase.TABLE, BaseColumns._ID, + "=?", new String[] {id.toString()});
Log.d(TAG, i + " records deleted where id is " + id);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你有一个流氓逗号:
应该是否则
它会尝试使用
+ "=?"
作为独立参数,而+
充当 一元运算符。You've got a rogue comma:
should probably be
Otherwise it's trying to use
+ "=?"
as a stand-alone argument with the+
acting as a unary operator.您的意思是
BaseColumns._ID + "=?"
而不是BaseColumns._ID, + "=?"
吗?编译器只会将
+
运算符的左侧视为空。Do you mean
BaseColumns._ID + "=?"
instead ofBaseColumns._ID, + "=?"
?The compiler just sees the left hand side of the
+
operator as being empty.请参阅 此文档介绍如何使用 db.delete 方法。而不是 BaseColumns._ID,+“=?” - 你应该这样做:
See this documentation on how to use the db.delete method. Instead of BaseColumns._ID, + "=?" - you should be doing this:
可爱的额外
,
(逗号)...喜欢逗号的本质,它意味着表达式和痛苦之间的分隔符...当你忽略它们时!Lovely extra
,
(comma)... love the commas for what they are, meaning a separator between expressions and a pain ... for when you overlook them!