title: Shared Preferences get lost after shutting down device or killing the app
body: <p>there are lots of questions out there related to shared preferences and the alternatives.
  My problem: when I shut down the device or kill the app, the shared preferences get lost.
  Please note that my code actually is working on Acer A500. But on my Motorola Xoom MZ604 it isn't working!!</p>
  
  <p>First of all I try to restore my HashSet in onCreate. This method is called for sure and is implemented in a singleton.</p>
  
  <pre><code>public boolean restoreCollection(Context context){
      SharedPreferences settings = context.getSharedPreferences(context.getString(R.string.restore_values), 0);
      if(settings.getStringSet(context.getString(R.string.collection), null) != null){
          collection = settings.getStringSet(context.getString(R.string.collection), null);
          return true;
      } 
      collection = new HashSet&lt;String&gt;();
      return false;
  }
  </code></pre>
  
  <p>By calling onDestroy I save the HashSet. Even though it isn't given, that this method is called for sure, the Preferences get lost in any case, I have trying to save it in onPause with the same result. </p>
  
  <pre><code>public void saveCollection(Context context){
      SharedPreferences settings = context.getSharedPreferences(context.getString(R.string.restore_values), 0);
      SharedPreferences.Editor e = settings.edit();
  e.putStringSet(context.getString(R.string.collection), collection);
  e.commit();
  }
  </code></pre>
  
  <p>Has had anyone problems with Shared Preferences and the XOOM device,too or am I the only one? Perhaps something is fishy with my code but the data doesn't get lost on my Acer Tablet.</p>
  
  <p>I've also tried PreferenceManager.getDefaultSharedPreferences(context) to get object of SharedPreferences</p>
  
  <p>Thanks for your help,
  Chris </p>