Code example for SharedPreferences

Methods: registerOnSharedPreferenceChangeListener

0
   * Runs on a worker thread, loading in our data. 
   */ 
  @Override 
  public SharedPreferences loadInBackground() {
    prefs=PreferenceManager.getDefaultSharedPreferences(getContext());
    prefs.registerOnSharedPreferenceChangeListener(this);
     
    return(prefs);
  } 
 
  @Override 
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                                        String key) {
    onContentChanged();
  } 
 
  /** 
   * Starts an asynchronous load of the list data. When the 
   * result is ready the callbacks will be called on the UI 
   * thread. If a previous load has been completed and is 
   * still valid the result may be passed to the callbacks