title: SharedPreferences in BroadcastReceiver seems to not update?
body: <p>I have a Activity which updates a string in the SharedPreferences.  </p>
  
  <pre><code>SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
  SharedPreferences.Editor editor = settings.edit();
  editor.putString("username", username);
  editor.commit();
  </code></pre>
  
  <p>I then start a service:</p>
  
  <pre><code>startService(new Intent(this, MyService.class));
  </code></pre>
  
  <p>The service creates a reference to Alarm which extends BroadcastReceiver:</p>
  
  <pre><code>Alarm alarm = null;
  public void onCreate() {
      alarm = new Alarm();
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      alarm.SetAlarm(this);
  }
  </code></pre>
  
  <p>In SetAlarm I do all the basic setting up stuff (At this point, "username" is still correct.. i checked):</p>
  
  <pre><code>public void SetAlarm(Context context) {
      AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
      PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
      am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), 1000 * 60 * interval, pi);
  }
  </code></pre>
  
  <p>I then stop the service and then start it again (using SetAlarm).</p>
  
  <pre><code>public void CancelAlarm(Context context) {
     Intent intent = new Intent(context, Alarm.class);
     PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
     AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
     alarmManager.cancel(sender);
  }
  </code></pre>
  
  <p>The issue is in onReceive.. the first time the "username" field is correct.  The second time, if username is updated between the service stopping and starting, however, it returns the first value.  The value does not seem to get updated...</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {   
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
      Log.e("hi", settings.getString("username", ""));
  }
  </code></pre>