开发者

Can I update an Android provider.Settings.System value?

开发者 https://www.devze.com 2022-12-24 17:17 出处:网络
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_O开发者_如何学CN);

I can read settings like this, for example:

final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_O开发者_如何学CN);

...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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消