title: Saving user selected gallery image in ImageView
body: <p>The goal of this activity is to allow the user to enter information and select an image from their gallery to display in an ImageView. </p>
  
  <p>Here is my code for selecting the image.</p>
  
  <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      switch (requestCode) {
          case SELECTED_PICTURE:
              if(resultCode==RESULT_OK){
                  Uri uri = data.getData();
                  String[]projection={MediaStore.Images.Media.DATA};
  
                  Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
                  cursor.moveToFirst();
  
                  int columnIndex = cursor.getColumnIndex(projection[0]);
                  String filePath = cursor.getString(columnIndex);
                  cursor.close();
  
                  Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
  
                  Drawable d = new BitmapDrawable(yourSelectedImage);
  
                  iv.setBackground(d);
  
              }
              break;
      }
  }
  </code></pre>
  
  <p>This works fine, but the photo goes away as soon as the user leaves. I need to be able to save the image path so I can call it on create, automatically setting the ImageView to the image they selected. </p>
  
  <p>What is the best way to do this?</p>