Java – How do I register SMS database changes?

How do I register SMS database changes?… here is a solution to the problem.

How do I register SMS database changes?

How do I register for SMS database changes?

I tried:

mCursor = mActivity.getContentResolver().query(Sms.CONTENT_URI, new String[] {
   }, null, null, null);

mydataSetObserver is implemented as follows:

 private class MyDataSetObserver extends DataSetObserver {
       public void onChanged() {
           System.out.println ("1");
       public void onInvalidated() {
            System.out.println ("2");

But when I try to send a text message in the emulator,
MyDataSetObserver is never called.

Can you tell me why?

Thank you.


It sounds like all you want is to be able to change the SMS database on your device.

The approach I’ve taken in the past is to use tags in AndroidManifest.xml. The application I created requires READ_SMS permissions as well as READ_CONTACTS permissions, but getting permission to write to the database will be done the same way.

I defined these required permissions in the AndroidManifest.xml file using the following markup:

Included in list of permissions, you can use WRITE_SMS, It should give you the features you need.

Please note: because I am a new user, StackOverflow only allows me to post a hyperlink for this post, I tried to include more information but was unable to do so. Go to the android developer site and search for AndroidManifest.xml files, and see more information if needed.

Related Problems and Solutions