我使用了下面的代码
String msgData = "";
Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
cursor.moveToFirst();
do{
for(int idx=0;idx<cursor.getColumnCount();idx++)
{
msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
}
}while(cursor.moveToNext()); ..and它可以工作,但它返回的数据比我想要的要多。
如何阅读最后3条短信(只有msg和sender)?
发布于 2012-11-15 02:03:37
只需按日期对结果进行排序,并使用limit子句:
getContentResolver().query(SMS_INBOX, new String[] {body, address},
null, null, "date desc limit 3");https://stackoverflow.com/questions/13384529
复制相似问题