title: Removing shared preferences also removes default image view
body: <p>I have an activity where a user can upload a photo. At first, before he chooses a photo there is a default image from the drawable folder. But, since I have shared preferences on that view, in case the user goes back to previous activities, I clean the shared preferences in the <code>onDestroy</code> of the main activity, and then when I launch my app again, the image view is blank, instead of displaying the default image.
  This is how I save the shared preferences:</p>
  
  <p>ActivityTwo.java;</p>
  
  <pre><code>public void onBackPressed() {
      SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
      SharedPreferences.Editor editor = preferences.edit();
      editor.putString("imageUri", imageURI);
      editor.apply();
      super.onBackPressed();
  } 
  </code></pre>
  
  <p>On the main activity I clean this preference:</p>
  
  <pre><code>@Override
  public void onDestroy()
  {
      super.onDestroy();
      SharedPreferences preferences = getSharedPreferences("Mypref", 0);
      preferences.edit().remove("imageUri").commit();
  }
  </code></pre>
  
  <p>But then when I launch the app again, the image view at the ActivityTwo is just a blank square, without the default image inside. </p>
  
  <p>So, am I doing it right? The way I clear the shared preferences? Why do I have to do it via the <code>onDestroy</code> of the main activity and not ActivityTwo?(It didnt work). And how to save the default image view? </p>
  
  <p>This is the xml of the image view:</p>
  
  <pre><code>&lt;ImageView
  android:id="@+id/imageView"
  android:layout_width="150dp"
  android:layout_height="150dp"
  android:layout_marginTop="40dp"
  android:background="@drawable/image_view_border"
  app:layout_constraintEnd_toEndOf="parent"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintTop_toTopOf="parent"
  app:srcCompat="@drawable/no_profile_picture" /&gt;
  </code></pre>