求android sqlite查询语句,比如载入时 查询user表,id为1的数据,代码该如何写?不要execSQL那种,感谢!

2025-05-18 14:25:38
推荐回答(2个)
回答1:

跟平常JAVA开发一样写呀
select * from user where id=1

回答2:

Integer类的参数不能放到selectionArgs里。参照下面的写法, id的值直接附在selection里
public void query(long id, String name) {
db.query("table", // table name
null, // columns
  "id=" +id + " AND name=?", // selection
new String[] {name}, //selectionArgs
//...... 更多参数省略
);
}