【问题标题】:What is the correct CONTENT_URI for the SMS thread table?SMS 线程表的正确 CONTENT_URI 是什么?
【发布时间】:2011-11-01 05:13:04
【问题描述】:
我正在尝试查询 SMS 线程表,但我似乎没有使用正确的 URI。
查询 URI“content://sms/conversations”给我列:
[thread_id, msg_count, sn-p]
查询 URI“content://mms-sms/conversations”给我列:
[正文、人、子、主题、retr_st、类型、日期、ct_cls、sub_cs、
_id,读取,ct_l,tr_id,st,msg_box,thread_id,reply_path_present,
m_cls、read_status、ct_t、状态、retr_txt_cs、d_rpt、error_code、
m_id,m_type,v,exp,pri,service_center,地址,rr,rpt_a,
resp_txt, 锁定, resp_st, m_size]
我正在寻找从 android/provider/Telephony.java 中的 Threads 表中提供值的 URI - data、recipient_ids、message_count、read 等...
谢谢
【问题讨论】:
标签:
android
android-contentprovider
【解决方案1】:
试试这个
Uri uri = Uri.parse("content://sms/");
你可以像这样得到你想要的
Uri uri = Uri.parse("content://sms/");
// List required columns
String[] reqCols = new String[] { "_id", "body" };
// Get Content Resolver object, which will deal with Content Provider
ContentResolver cr = context.getContentResolver();
// Fetch Sent SMS Message from Built-in Content Provider
Cursor cursor = cr.query(uri, reqCols, "address = '" + number + "'", null, null);
// Attached Cursor with adapter and display in listview
adapter = new SimpleCursorAdapter(context, R.layout.single_conversation_view, cursor, new String[] {"body" }, new int[] { R.id.tv_single_conversation_message }, 1);
lv_single_conversation.setAdapter(adapter);
希望对你有帮助