preferences

Android boolean preference problem

房东的猫 提交于 2019-12-24 23:33:22
问题 I want to have the status of a checkbox be saved into my prefs. I set a listener on the checkbox, and if it is checked I do a prefs.putBoolean("cbstatus", true), and it is it unchecked i do a prefs.putBoolean("cbstatus", false); Trouble is, in my onStart() when I get prefs, my Boolean getcbstatus = prefs.getBoolean("cbstatus", false); will always return a true, regardless of how my listener should have set that status previously. What am I doing wrong? I have working prefs for other things

How to make things done on Preferences being changed?

≯℡__Kan透↙ 提交于 2019-12-24 15:53:20
问题 I've set up a Preference Screen as a settings option in my App, but I am totally confused about how to make the changes done when user selects or changes an Option. Here's the xml code of my PreferenceScreen: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory android:title="Notifications"> <RingtonePreference android:summary="Choose a Ringtone" android:title="Notification Ringtone" android:key="ringtonePref

using getPreferece() to set a first time run flag

霸气de小男生 提交于 2019-12-24 09:58:45
问题 I have this code that should read an unset preference on the first run: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences settings = getPreferences(MODE_PRIVATE); firstTime = settings.getBoolean("firstTime", true); Log.d("mything", "firstTime returns as: " + firstTime); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("firstTime", false); editor.commit(); the variable "firstTime" is always returned as false. I am

Managing multiple SharedPreference files

拥有回忆 提交于 2019-12-24 07:33:40
问题 I'm looking for a good way to manage multiple SharedPreference files. Basically the user should be able to create, edit, and delete the preference files and then select the one they want from a spinner. What I'm trying to figure out is how do I find all of the preference files that the app has? Is there a way to scan the directory and return the names of all of the preference files? I'm thinking that once I get a lits of all of the names I could create a string array with all of the names and

How to clear data in Preference Store when uninstalling an Eclipse plugin?

耗尽温柔 提交于 2019-12-24 07:13:03
问题 I'm developing an Eclipse-Plugin which has it's own preference page. I'm storing some data using IPersistentPreferenceStore, but would like to remove / clear this data upon uninstall of my plugin. Otherwise, whenever I re-install the plugin, I get the old data loaded again from previous installations. So far I was not successful in finding any hooks / events for eclipse plugin uninstall to notify my plugin. Does anyone have an idea? 回答1: A way is that your plug-in explicitly registers a

Android - App keeps crashing with error - I think it has to do with Preference Fragments

老子叫甜甜 提交于 2019-12-24 02:58:05
问题 I keep getting an error that has to do with the preferences and I know it has depreciated so I looked here for help http://developer.android.com/reference/android/preference/PreferenceFragment.html and I did exactly as it says on the bottom part... Here is the error: 12-04 00:39:37.553: E/AndroidRuntime(1164): FATAL EXCEPTION: main 12-04 00:39:37.553: E/AndroidRuntime(1164): Process: com.proteintracker, PID: 1164 12-04 00:39:37.553: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable

Starting custom PreferenceActivity INSIDE another PreferenceActivity

淺唱寂寞╮ 提交于 2019-12-24 00:33:54
问题 Inside my Configuration activity i need to create a preference screen with a fixed View at the top showing a preview of content configured in the page. I don't want to change the main preference screen (i have already a separate activity for that) i want a different layout for a "nested" preferencescreen. What i've tried is specifying an Intent inside the preference screen however when i click on this options nothing happens and activity goes into timeout... Activity is correctly configured

Hide a preference screen in android

冷暖自知 提交于 2019-12-23 20:29:46
问题 I have a preference xml .. first im loading the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); and setting some default values to it... After setting the default values , i need to hide (not to remove) one of my preference screen My preference XML is <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <Preference android:title="Account Settings" android:key="customPref" /> <PreferenceScreen android:title="@string/account_1" android

Android store array in preferences

隐身守侯 提交于 2019-12-23 17:19:29
问题 I know only primitives can be stored in the android preferences, but do arrays count? Can I store an array of, say, Strings or booleans in an android preference? 回答1: Only if you turn the array into a string. 回答2: SharedPreferences settings = getSharedPreferences(PREFS_NAME,0); for(int n =0;n<LevelMenu.buttonState.length;n++){ LevelMenu.buttonState[n]= (byte) settings.getInt("levelsave"+n,0); } Above will get and populate the array and below will depopulate and save. SharedPreferences

How to set multiple default values in a MultiSelectListPreference?

◇◆丶佛笑我妖孽 提交于 2019-12-23 06:55:02
问题 I have preference.xml like this <MultiSelectListPreference android:key="store_select" android:title="@string/setting_store_title" android:summary="@string/setting_store_summary" android:dialogTitle="@string/setting_store_dialog_title" android:entries="@array/store_names" android:entryValues="@array/stores" android:defaultValue="@array/stores" /> with my two arrays: <string-array name="stores"> <item>1</item> <item>2</item> <item>3</item> <item>4</item> <item>5</item> </string-array> <string