我想从一个联系人那里获得所有消息。我有联系人 ID _id
,所以我已经做了这样的事情:
private void displayMessages() {
ContentResolver cr = this.getContentResolver();
try {
Cursor cursor = cr.query(Uri.parse("content://mms-sms/conversations"), new String[]{"*"}, this.contID + "= _id" , null, null); //contID is the unique ID for one contact in our android.
while (cursor.moveToNext()) {
System.out.println("Number: " + cursor.getString(cursor.getColumnIndexOrThrow("address")));
System.out.println("Body : " + cursor.getString(cursor.getColumnIndexOrThrow("body")));
}
cursor.close();
}
catch (Exception e) {
System.out.print("ERROR");
}
我问过类似的东西
SELECT * FROM content://mms-sms/conversations WHERE _id = contID
如您所见,在我的查询中,我向系统询问来自一个联系人(我知道的用户 ID)的消息,但我只能显示最后一条消息正文。所以我认为存在其他查询来获取来自一个用户的所有消息?
有任何想法吗 ???