tags:

views:

495

answers:

1

I can read settings like this, for example:

final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);

...but can't seem to write to settings using putString, no matter what I've tried. Maybe it is the scope of this.getContentResolver()??? I'm a newbie, so who knows, maybe it can't be done, or it's just syntax? Currently the code is in the onCreate of an Activity class.

Any insight is much appreciated.

+1  A: 

Have you given your app WRITE_SETTINGS permission in AndroidMainfest.xml?

If not you will see this:

E/AndroidRuntime(11614): Caused by: java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=11614, uid=10053 requires android.permission.WRITE_SETTINGS

I strongly advise looking at the log output when debugging this kind of thing.

Jim Blackler
Thanks Jim, that was definitely my problem. I was looking at the console window and the debug window in Eclipse, but nothing was popping up. After your comment, I figured I must be missing something... sure enough I found the LogCat window - and there was my Security exception. Thanks again!
Mr_Ed