query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder);
方法中没有group by的参数,这个方法毕竟是别人封装的sql语句,于是我把group by放在了selection里。结果报错了。
在网上找了一下,原来是 拼接的不对。and后面加一个查询语句。方式如下
String[] projection =
new
String[] {
"_id"
,
"thread_id"
,
"address"
,
"person"
,
"body"
,
"date"
};
Cursor cursor = context.getContentResolver().query(SMS_PROVIDER,
projection,
"0=0) group by (thread_id"
,
null
,
"date desc"
);