-1

I have my question in the following link SmS count not increasing. message id is constant any one please answer. thanks for help.

Community
  • 1
  • 1
thej
  • 648
  • 10
  • 33

2 Answers2

2
Uri sms_content = Uri.parse("content://sms");
Cursor c = this.getContentResolver().query(sms_content, null,null, null, null);

And now you can work with Cursor c. like c.getCount() for total Sms

There are more options like content://sms/sent or content://sms/inbox.

And don't forget to Give Permission.

<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
Bhavin
  • 6,020
  • 4
  • 24
  • 26
1

If you are interested to track only incoming SMS it would be better to use a Broadcast with action android.provider.Telephony.SMS_RECEIVED that will track it better than ContentObserver. Try this one.

Community
  • 1
  • 1
Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242