【发布时间】:2012-08-12 10:57:59
【问题描述】:
我测试了 sql,它在 Sqlite Spy 中运行良好:
select ifnull(_name, _number) as identifer, count(_id) as amount from call group by identifer
我想在 ContentConsolver 中使用它,但它不能与“group by”一起使用:
String[] projections = new String[] { "ifnull(name, number) as identifer", "count(_id) as amount" };
String group = "identifer";
//String selection = ") GROUP BY (" + group;
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, projections, null, null, null /*!group*/ );
我该怎么办?
【问题讨论】:
-
如果
ContentProvider查询的ContentResolver不公开带有group-by 的URI 或不支持group-by 参数的某些URI 参数,您将不得不进行分组阅读Cursor的全部内容后在Java代码中。 -
暂时解决,ICS 出错!添加: String selection = " 1 = 1 ) GROUP BY (identifer";