You can use Preference classes from Android SDK to store, set and retrieve Settings at application level or at activity level.

There are 2 ways to manipulate preferences :

  1. Using your own screen to modify the settings
  2. Using the built in PreferenceActivity class

Let’s take a look :

Part 1. Use your own screen

  1. Create your own screen using layouts
  2. Define a name for preference file
    1. public static final String PREFS_NAME = "MyPrefsFile";
  3. Restore preferences
    1. SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    2. boolean silent = settings.getBoolean("silentMode", false);
  4. Edit preference
    1. //We need an Editor object to make preference changes.
    2. // All objects are from android.context.Context
    3. SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    4. SharedPreferences.Editor editor = settings.edit();
    5. editor.putBoolean("silentMode", mSilentMode);
  5. Commit the edits!
    1. editor.commit();
    1. If you want to store preference only for current activity use getPreferences(mode)

Part 2 : Use PreferenceActivity

  1. Create a class that extends PreferenceActivity : public class Preferences extends PreferenceActivity
  2. Create a xml file that contain Preference screen layout
    1.  
  3. There are many available fields : CheckBoxPreference, EditTextPreference, RingtonePreference, ListPreferenceIf you want to open a new screen for specific preferences you can wrap them in a PreferenceScreen tag.
  4. Find preference by key :
    1. mListMeasurementUnits = (ListPreference)getPreferenceScreen().findPreference(KEY_LIST_MEASUREMENTUNITS);
  5. If you want to show changes in the preferences screen, you may use :
    1. public class Preferences extends PreferenceActivity implements OnSharedPreferenceChangeListener
    2. public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    3. mListMeasurementUnits.setSummary("Current value is : " + sharedPreferences.getString(key, "Not set") );
    4. }
    5.  
    6. @Override
    7.         protected void onPause() {
    8.                 // Unregister the listener whenever a key changes
    9.         getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);  
    10.  
    11.  super.onPause();
    12.  }
    13.  
    14. @Override
    15.         protected void onResume() {
    16.  
    17.                 // Set up a listener whenever a key changes
    18.                 sharedPreferences.registerOnSharedPreferenceChangeListener(this);
    19.  
    20.                 super.onResume();
    21.         }
  6. Retrieve settings from any activity or service that run in the same context as PreferenceActivity
    1. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

Source : http://developer.android.com/guide/topics/data/data-storage.html#pref