Difference b/w Settings.Global ,Settings.System and Settings.Secure in android

纵然是瞬间 提交于 2021-02-18 22:17:58

问题


There are 3 inner classes in android.provider.Settings:

  1. Global
  2. System
  3. Secure

Each class has a different type of Preference. Can someone explain the role/scope of each of these classes?


回答1:


From the Android developer docs:

  • Settings.System : System settings, containing miscellaneous system preferences. This table holds simple name/value pairs. There are convenience functions for accessing individual settings entries.
  • Settings.Secure : Secure system settings, containing system preferences that applications can read but are not allowed to write. These are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values, not modified directly by applications.
  • Settings.Global : Global system settings, containing preferences that always apply identically to all defined users. Applications can read these but are not allowed to write; like the "Secure" settings, these are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values



回答2:


Settings.Global was introduced in API 17, and now contains some values that were previously stored in Settings.System.

e.g. prior to API 17, the Device Name was stored in Settings.System, and now it is stored in Settings.Global.

(see related post for info on that: Android : Get “device name” on android tv)




回答3:


Settings.Secure is same like Settings.Global Both are can be modified only by Settings apps or SystemUI app and other apps can read them Only difference is that Global will be applied to all users

On the other hand Settings.System can be modified by apps that uses dynamic preferences or other system apps



来源:https://stackoverflow.com/questions/35989475/difference-b-w-settings-global-settings-system-and-settings-secure-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!