简体   繁体   English

相当于Android中的plist

[英]Equivalent of plist in Android

I have developed an application on native iOS platform where I was reading user settings from the plist.我在本机iOS平台上开发了一个应用程序,我正在从 plist 读取用户设置。

string settingsBundle = NSBundle.MainBundle.PathForResource ("Settings.bundle/Root", @"plist");
NSDictionary dic = NSDictionary.FromFile (settingsBundle);

I wonder what is the common way of doing it in the Android or Xamarin.Android我想知道在AndroidXamarin.Android中执行此操作的常用方法是什么

You can put default user settings in preferences.xml :您可以将默认用户设置放在首选项.xml 中:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="pref_sync"
        android:title="@string/pref_sync"
        android:summary="@string/pref_sync_summ"
        android:defaultValue="true" />
    <ListPreference
        android:dependency="pref_sync"
        android:key="pref_syncConnectionType"
        android:title="@string/pref_syncConnectionType"
        android:dialogTitle="@string/pref_syncConnectionType"
        android:entries="@array/pref_syncConnectionTypes_entries"
        android:entryValues="@array/pref_syncConnectionTypes_values"
        android:defaultValue="@string/pref_syncConnectionTypes_default" />
</PreferenceScreen>

and read it like this:并像这样阅读:

SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String syncConnPref = sharedPref.getString(SettingsActivity.KEY_PREF_SYNC_CONN, "");

See more details at Defining Preferences in XML请参阅在 XML定义首选项中的更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM