Android sms reading by number

I am working on an SMS application. in my application I have to list all convrsation.SO I use the following Uri.

content://mms-sms/conversations/ 

His working tone. And the next piece of code.

  Uri uri = Uri.parse("content://mms-sms/conversations/"); Cursor c= getContentResolver().query(uri, null, null ,null,null); startManagingCursor(c); if(c.moveToFirst()){ for(int i=0;i<c.getCount();i++){ body[i]= c.getString(c.getColumnIndexOrThrow("body")).toString(); number[i]=c.getString(c.getColumnIndexOrThrow("address")).toString(); c.moveToNext(); } } c.close(); for (int i = 0; i < body.length; i++) { System.out.println("body ="+body[i]); System.out.println("number ="+number[i]); } 

A number prints each thread number, and a body prints every last message. But I want to receive every message of whole messages, and also help me in a conversation for a certain number.

+4
source share
1 answer

From the Conversations cursor you can get thread_id . After you got thread_id , continue the request from sms provider to return the whole message with the same thread_id

Example: thread_id = 2

 Uri SMS_INBOX = Uri.parse("content://sms"); Cursor c = getContentResolver().query(SMS_INBOX, null, "thread_id" + " = " + "2", null, "date" + " ASC"); while (c.moveToNext()){ Log.v("BODY", c.getString(11).toString()); // 11 is the index of body with project URI } 
+1
source

All Articles