Skip to content Skip to sidebar Skip to footer

Getting Phone Number Of Each Sms Via Content://sms/

I've wrote the following code, to get the whole conversation between the user and a number: Uri SMS_INBOX = Uri.parse('content://sms/'); String selection = 'thread_id = ' +

Solution 1:

The column will always gives second persons number only.If you want to differentiate sent message and received message you have to use column 'type'.

body[i] = c.getString(c.getColumnIndexOrThrow("body")).toString();

if(c.getString(c.getColumnIndex("type")).equalsIgnoreCase("1")){

                // sms received

                msg_state[i]=1;

             }

              else {
                //sms sent
                msg_state[i]=0;

             }

No You can easily identify the sent sms and received sms.

Post a Comment for "Getting Phone Number Of Each Sms Via Content://sms/"