SMS线程表的正确CONTENT_URI是什么?

时间:2011-08-22 14:29:23

标签: android android-contentprovider

我正在尝试查询SMS线程表,但我似乎没有使用正确的URI。

查询URI“content:// sms / conversations”为我提供了以下列:

  

[thread_id,msg_count,snippet]

查询URI“content:// mms-sms / conversations”为我提供了以下列:

  

[body,person,sub,subject,retr_st,type,date,ct_cls,sub_cs,   _id,read,ct_l,tr_id,st,msg_box,thread_id,reply_path_present,   m_cls,read_status,ct_t,status,retr_txt_cs,d_rpt,error_code,   m_id,m_type,v,exp,pri,service_center,address,rr,rpt_a,   resp_txt,locked,resp_st,m_size]

我正在寻找从android / provider / Telephony.java中的Threads表中提供值的URI - data,recipient_ids,message_count,read等...

由于

1 个答案:

答案 0 :(得分:-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);

希望它会帮助你