android sharedpreferences set value

It depends on whether you are after one set of preferences for your application, or one set per activity. I’ve used code like this: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); Editor editor = prefs.edit(); editor.putBoolean(PREF_NAME, false); editor.commit(); and SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); if (prefs.getBoolean(PREF_NAME, true)) { // etc }

Preferences screen using ActionBar Sherlock

onBuildHeaders() will only be called if you are running on API Level 11 or higher. On older devices, you are back to the classic addPreferencesFromResource() approach. See this sample project for an example of supporting PreferenceFragment on API Level 11+ and classic preferences on older versions of Android. Specifically, its SherlockFragmentActivity looks like: package com.commonsware.android.preffragsbc; … Read more

How to remove PreferenceCategory programmatically?

you can hide a category by getting reference to PreferenceScreen: I your xml : <PreferenceScreen xmlns:android=”http://schemas.android.com/apk/res/android” android:key=”@string/preferenceScreen”> //set all you values //Preference, PreferenceCategory and/or CheckBoxPreference </PreferenceScreen> in you string.xml : don’t forgot to set this new string <string name=”preferenceScreen” translatable=”false”>preferenceScreen</string> in you code: preferenceScreen = (PreferenceScreen) findPreference(getResources().getString(R.string.preferenceScreen)); and then remove the category from your PreferenceScreen … Read more

Where are Java preferences stored on Mac OS X?

From Apple Developer Connection: The preferences files generated by the Preferences API are named com.apple.java.util.prefs. The user’s preferences file is stored in their home directory (~/Library/Preferences/). The system preferences are stored in /Library/Preferences/ and are only persisted to disk if the user is an administrator.

Android shared preferences not saving

From the documentation: Create a new Editor for these preferences, through which you can make modifications to the data in the preferences and atomically commit those changes back to the SharedPreferences object. Since that’s a new Editor instance, your code should be more like this: preferences = getApplicationContext().getSharedPreferences(PREFERENCES_NAME, 0); SharedPreferences.Editor editor = preferences.edit(); editor.putString(SETTINGS_BACKGROUND_IMAGE, “okok”); … Read more

Android: No Activity found to handle Intent error? How it will resolve

Add the below to your manifest: <activity android:name=”.AppPreferenceActivity” android:label=”@string/app_name”> <intent-filter> <action android:name=”com.scytec.datamobile.vd.gui.android.AppPreferenceActivity” /> <category android:name=”android.intent.category.DEFAULT” /> </intent-filter> </activity>

Cocoa – Notification on NSUserDefaults value change?

Spent all day looking for the answer, only to find it 10 minutes after asking the question… Came across a solution through Key-Value-Observing: [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@”values.MyPreference” options:NSKeyValueObservingOptionNew context:NULL]; Or, more simply (per comment below): [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@”MyPreference” options:NSKeyValueObservingOptionNew context:NULL];

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)