开发者

Unable to read from content://sms/all

开发者 https://www.devze.com 2023-04-12 18:59 出处:网络
I\'m developing an app which requires threaded sms.I was able to retrieve contents from inbox, but in the threaded view sms must be filled with both inbox and sent items.

I'm developing an app which requires threaded sms. I was able to retrieve contents from inbox, but in the threaded view sms must be filled with both inbox and sent items.

Separately both content://sms/inbox and content://sms/sent are working well.

How do I join contents from two URI's and order by time?

Can I use content://sms/all?

Null value is returned for cursor when ALL CONTENT URI is used.

开发者_JAVA技巧

How to do this?


At last found the answer for this..

content://sms/all

is something which i couldnt find.

But for retrieving both sent and received we can use

Uri selectUri = Uri.parse("content://sms/");

Cursor cur = getContentResolver().query(selectUri,null,"thread_id="+threadid, null,"DATE desc");

This snippet fetches and displays in descending order

Thanks all


I had the same issue. For this,you can use MatrixCursor.What I have done is-

  1. Get all sms from content://sms/inbox for a thread_id

  2. Get all sms from content://sms/sent for a thread_id

  3. Maintain an arraylist and sort them in the order you want(I did this using bubble sort)

  4. Now define and initialize the matrixCursor

    (Refer this: http://groups.google.com/group/android-developers/browse_thread/thread/470dd3a1703848eb/d7e70618ce413261?q=MatrixCursor+join+two+tables for MatrixCursor )

  5. Add all the sorted records to your matrixCursor

    (Please note that adding this record should be in the sequence of at what time and from which folder(inbox or sent) they come.MatrixCursor simply lets you create a custom cursor so you need to maintain the sequence.)

0

精彩评论

暂无评论...
验证码 换一张
取 消