1
我有一个SQLite数据库,我通过SimpleCursorAdapter从数据库中获取一个ListView。这是现有的代码:数据库到ListView - 筛选出条目
Cursor c = mDatabase.query(
"database",
bla = new String[]{
"_id",
"title",
"message",
"time",
"date",
"done"
},
null, null, null, null, null);
startManagingCursor(c);
SimpleCursorAdapter listAdapter =
new SimpleCursorAdapter(this,
R.layout.list_item, c,
new String[]{"title", "message", "time", "date"},
new int[]{R.id.txtv_title, R.id.txtv_message, R.id.txtv_time, R.id.txtv_date}
);
setListAdapter(listAdapter);
这按预期工作,我得到我的ListView。 现在我想如果我的数据库中的“完成”字段包含字符串“false”(而不是“true”...),此行不进入ListView。
我该怎么做? 在此先感谢!
这是解决了,谢谢您!我甚至没有考虑用查询来做这件事...... – CTrox 2011-04-20 17:53:11
但是,您可以通过查询方法提供位置和顺序,而无需使用rawQuery ...方法查询更适合于保留rawQuery fx u可以存储静态列数组和表格名称所以你可以在一个地方改变它,而不是在每个查询字符串 – Selvin 2011-04-20 18:01:49
我不是简单查询()方法的粉丝,因为我能够使用SQL,所以为什么要使用这些东西来为我做这些事情?当然,你也可以使用这种方法,结果应该是一样的。 – 2011-04-20 18:05:35