Settings屬性讀寫

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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容