title: Can't load Image into an ImageView
body: <p>I'm having a problem loading an image from the gallery in my Android app. I have some code that picks an image in emulator. When I make a selection, an exception is thrown and caught, meaning the image doesn't load, but I'm not sure how to diagnose what's happening.</p>
  
  <p>Here is my java code file:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      galleryImage = (ImageView) findViewById(R.id.imageView);
      pick_btn = (Button)findViewById(R.id.button);
      pick_btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
              startActivityForResult(i,RESULT_LOAD_IMG);
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      try {
  
          if (requestCode == RESULT_LOAD_IMG &amp;&amp; resultCode == RESULT_OK &amp;&amp; null != data) {
              Uri selectedImage = data.getData();
              String[] filePathColumn = {MediaStore.Images.Media.DATA};
  
              Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
              Log.i("Image Column Index..", "hoiiii");
              assert cursor != null;
              cursor.moveToFirst();
  
              int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
              picturePath = cursor.getString(columnIndex);
              cursor.close();
  
              galleryImage.setImageBitmap(BitmapFactory.decodeFile(picturePath));
          }
      }catch (Exception e)
      {
          Toast.makeText(getApplicationContext(),"You haven't picked any image",Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>}</p>