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