New Command Line Tool ‘settings’ in Android 4.2

There is a new binary shipping with Android Jellybean 4.2, which can be used to directly read/write to the system settings provider, accessible via command line.

This tool also makes it easy to change system settings using shell commands (Github source). Since adb is run as a system process, using ‘adb shell’ allows full read/write. If these commands are run from within an application, it requires the appropriate permissions unless it is being run with elevated permissions (root).
usage: settings [--user NUM] get namespace key
settings [--user NUM] put namespace key value
'namespace' is one of {system, secure, global}, case-insensitive
If '--user NUM' is not given, the operations are performed on the owner user.

Corresponding keys can be found in the frameworks core (Github source).

It can be used to get system state without explicit API calls. For example, change screen brightness to 200 (1-255):

settings put system screen_brightness 200