android中sqlite的按条件查找的小例子
程序员文章站
2023-11-04 14:23:58
name hobby
tom  ...
name hobby
tom football
peter basketball
我们如果要查找爱好是football的一行数据怎么办呢?在网上找了很多方法,感觉都说不到点子上,所以浪费了很多时间,好在终于解决了,解决方法如下
[java]
复制代码 代码如下:
cursor mcursor=msqlitedatabase.query(tablename, new string[]{"id as _id","name","hobby"},"hobby=?", new string[]{hobbyinput}, null, null, null);
cursor mcursor=msqlitedatabase.query(tablename, new string[]{"id as _id","name","hobby"},"hobby=?", new string[]{hobbyinput}, null, null, null);
主要就是这样一个语句 怎么这么简单的一句话,网上很多人写的都不对, 注意hobbyinput是一个变量,可以写成football或者basketball 再或者就是你定义的一个形参