Changing Android system settings (eg. airplane mode radios) via commandline (on rooted phones)

There's this old question at stackoverflow.com about how to change system settings stored via android.provider.Settings.System using a shell command. The answer is: SQLite.

I'm not sure about older Android versions, but in 4.* the above settings are stored in the SQLite database at /data/data/com.android.providers.settings/databases/settings.db. The older android.provider.Settings.System settings are in a table called system and the newer android.provider.Settings.Global settings are in a tabled called global (and then there're the android.provider.Settings.Secure settings in the secure table too). If you've root access and an SQLite binary (eg. Titanium Backup installs an SQLite3 binary into /data/data/com.keramidas.TitaniumBackup/files/sqlite3), you can update system settings using a simple SQL update. Smile
Eg.
sqlite3 "/data/data/com.android.providers.settings/databases/settings.db" "update global set value = 'bluetooth,wifi,nfc' where name = 'airplane_mode_toggleable_radios';"

Of course for this to work you need write access to this settings.db file which requires root privileges ... which requires a rooted phone. In this older CyanogenMod forum post somebody describes a read-write remount of /data to gain write access to the settings.db. Maybe in older Android versions /data was initially mounted read-only?

The above database update however does not apply the new settings immediately. You probably have to reboot the phone for these changes to take effect. If you want instant changes without a reboot, then you've to revert back to coding and use the put*() functions of the mentioned android.provider.Settings.* classes to set system settings. Your app will need the android.permission.WRITE_SETTINGS (or android.permission.WRITE_SECURE_SETTINGS) permission though.