Settings系統屬性存儲均為xml,分三種:
1.global:所有的偏好設置對系統的所有用戶公開,第三方APP有讀沒有寫的權限;
源碼地址:frameworks/base/core/java/android/provider/Settings.java
對應xml路徑:/data/system/users/0/settings_global.xml
adb指令讀寫方法: 先adb shell進入終端。
????????????????????????????????讀為settings get global 系統屬性key
????????????????????????????????寫為settings put?global 系統屬性key 系統屬性值
Java代碼讀寫為(寫權限要求系統app)??
Settings.Global.getLong(context.getContentResolver(), key, defaltValue);
Settings.Global.putLong(mContext.getContentResolver(), key, value);
2.system:包含各種各樣的用戶偏好系統設置;
對應xml路徑:/data/system/users/0/settings_system.xml
?adb指令讀寫方法: 先adb shell進入終端。
????????????????????????????????讀為settings get system?系統屬性key
????????????????????????????????寫為settings put system?系統屬性key 系統屬性值
Java代碼讀寫為(寫權限要求系統app)??
Settings.System.getLong(context.getContentResolver(), key, defaltValue);
Settings.System.putLong(mContext.getContentResolver(), key, value);
3.secure:安全性的用戶偏好系統設置,第三方APP有讀沒有寫的權限。
對應xml路徑:/data/system/users/0/settings_secure.xml
adb指令讀寫方法: 先adb shell進入終端。
?????????????????????????????????讀為settings get secure 系統屬性key
????????????????????????????????寫為settings put?secure 系統屬性key 系統屬性值
Java代碼讀寫為(寫權限要求系統app)??
Settings.Secure.getLong(context.getContentResolver(), key, defaltValue);
Settings.Secure.putLong(mContext.getContentResolver(), key, value);
4.其他
列出global配置表中的所有屬性值
settings list global
檢索對應的屬性值
settings list global |grep disable
刪除屬性值
settings delete global disable_list