正在加载图片...
Reading shared Preferences To read shared preference values o Use SharedPreferences "get methods such as getBoolean(String key, boolean defvalue)and getstring(string key, String defvalue) o The get methods have two parameters key: the preference key string defvalue: a default value to return if the preference is undefined / Restore the preferences // Get the preference with the name specified SharedPreferences settings get sharedPreferences(PreFs NAME, 0); / Read the stored data from the preference int data settings getInt("key", defaultvalue); 13Reading Shared Preferences • To read shared preference values: o Use SharedPreferences “get” methods such as getBoolean(String key, boolean defValue) and getString(String key, String defValue). o The “get” methods have two parameters ▪ key: the preference key string ▪ defValue: a default value to return if the preference is undefined // Restore the preferences // Get the preference with the name specified SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); // Read the stored data from the preference int data = settings.getInt(“key", defaultValue); 13
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有