title: How to get path data from image in gallery by using Content Resolver
body: <p>I already successfully get the image from gallery but i cannot upload the image to server because the file is null. is there any code that i miss to add? i add imageView.getPath, but i only get the path from camera image to server, and get null image from gallery.</p>
  
  <p>i got this path, content://com.android.providers.media.documents/document/image%3A5755
  but still cannot upload to server</p>
  
  <pre><code>private void getImageFromGallery(Intent data) {
  
      mSelectedImgURI = data.getData();
  
      mimeType = getImageExt(mSelectedImgURI);
      uploadDialog.dismiss();
  
      imgCategory.setImageURI(mSelectedImgURI);
  }
  
  private void getImageFromCamera(Intent data) {
  
      Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
  
      String tempFileName = System.currentTimeMillis() + ".jpg";
      File destination = new File(Environment.getExternalStorageDirectory(),tempFileName);
      FileOutputStream fo;
  
      try {
  
          destination.createNewFile();
          fo = new FileOutputStream(destination);
          fo.write(bytes.toByteArray());
          fo.close();
  
          mSelectedImgURI = Uri.fromFile(destination);
          uploadDialog.dismiss();
          imgCategory.setImageBitmap(thumbnail);
  
      } catch (IOException e) {
          Log.d(TAG, "Internal error - " + e.getLocalizedMessage());
      }
  }
  
  public String getImageExt(Uri uri){
      ContentResolver contentResolver = getApplicationContext().getContentResolver();
      MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
      return mimeTypeMap.getExtensionFromMimeType(contentResolver.getType(uri));
  }
  </code></pre>