title: Android shared preferences not saving
body: <p>I've created an Android live wallpaper and i'm trying to let a user choose an image from their phone and apply it as a background image, but when I launch the activity that start the intent to pick the images, my shared preferences don't seem to save properly.</p>
  
  <p>Below is my onCreate method of the activity I start when the users presses the preference button, and the onActivityResult which gets the path of the image on the device (all that seems to work). The println after I commit the preferences prints out nothing. </p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
      photoPickerIntent.setType("image/*");
      startActivityForResult(photoPickerIntent, SELECT_PICTURE);
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (resultCode == RESULT_OK) {
          if (requestCode == SELECT_PICTURE) {
              Uri selectedImageUri = data.getData();
              selectedImagePath = getPath(selectedImageUri);
  
              preferences = getApplicationContext().getSharedPreferences(PREFERENCES_NAME, 0);
              preferences.edit().putString(SETTINGS_BACKGROUND_IMAGE, "okok");
              preferences.edit().commit();
  
              System.out.println("Image" + preferences.getString(SETTINGS_BACKGROUND_IMAGE, ""));
          }
      }
  
      finish();
  }
  </code></pre>