Monitor Android system settings values

Here's some example code:

ContentResolver contentResolver = getContentResolver();
Uri setting = Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION);

// Make a listener
ContentObserver observer = new ContentObserver(new Handler()) {
    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
    }

    @Override
    public boolean deliverSelfNotifications() {
        return true;
    }
};

// Start listening
contentResolver.registerContentObserver(setting, false, observer);

// Stop listening
contentResolver.unregisterContentObserver(observer);

Check out the documentation for any of these methods for more details.


here is how it can be done, works great: How to implement a ContentObserver for call logs. note than some settings are first written / reallly changed when the user presses the back key in the system preference screen where he changed something!