我在 res/xml/preferences.xml 中的应用程序中有以下代码:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Wi-Fi settings">
<EditTextPreference
android:key="pref_voice_threshold_top"
android:title="@string/title_pref_voicetopthreshold"
android:dialogTitle="@string/dialog_title_pref_voicetopthreshold"
android:defaultValue="20"
android:inputType="number"/>
</PreferenceCategory>
</PreferenceScreen>
我想知道我是否可以在代码中使用此首选项,以便我可以通过下载 xml 文件来更新它?
所以我目前在 PreferenceActivity 中显示上述首选项,效果很好,但是我希望能够通过每周从 Internet 下载一个新设置来更新设置。
所以我的问题是如何在代码中打开此首选项并将其值设置为新下载的值?