ContentResolver cr = getContentResolver();
String[] projection = new String[]{"body", "ct_t", "_id", "address"};
Uri uri = Uri.parse("content://mms-sms/conversations/" + id);
Cursor c = cr.query(uri, projection, null, null, null);
这将查询来自特定对话的所有消息,我希望仅显示已发送的消息,因为我需要区分对话的每一方。 是否像这样的uri这样的东西:
Uri uri2 = Uri.parse("content://mms-sms/conversations/" + id + "/sent/");
答案 0 :(得分:1)
您需要在投影中添加几列,并在query()
调用中包含选择参数。
final String[] projection = {"_id", "address", "body", "ct_t", "type", "msg_box"};
final String selection = "(type = 2 OR msg_box = 2)";
final Uri uri = Uri.parse("content://mms-sms/conversations/" + threadId);
Cursor c = getContentResolver().query(uri, projection, selection, null, null);
短信在发送时的type
值为2
。 MMS邮件将具有相同的值,但在msg_box
列中。