title: How to get path of a captured image in android
body: <p>I am working on an android application. It has a functionality that captured image should display on screen and I need to get that image path, so that I can send that image to server.</p>
  
  <p>I am able to display image on screen, but unable to get absolute image path.</p>
  
  <p>I am getting path like:</p>
  
  <pre><code>content://media/external/images/media/1220
  content://media/external/images/media/1221
  </code></pre>
  
  <p>How can I get actual image path?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>mintent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  mintent.putExtra(MediaStore.EXTRA_OUTPUT,
                   MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString());
  startActivityForResult(mintent, 1);
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if ((data != null &amp;&amp; !data.toString().equalsIgnoreCase("Intent {  }"))
        || requestCode == 1)
      switch (requestCode) {
        case 1:
          try {
            // Uri imageFileUri = data.getData();
            // String path=getRealPathFromURI(this,imageFileUri);
            // Bitmap bitmap = (Bitmap) data.getExtras().get("data");
  
            String photoPath = null;
            Bitmap bitmap = (Bitmap) data.getExtras().get("data");
            Intent intent = new Intent(this, Media.class);
            intent.putExtra("BitmapImage", bitmap);
  
            Bundle b = mintent.getExtras();
            if (b != null &amp;&amp; b.containsKey(MediaStore.EXTRA_OUTPUT)) { // large
              // image?
              String timeStamp = new SimpleDateFormat(
                  "yyyyMMdd_HHmmss").format(new Date());
              // Shouldn't have to do this ... but
              photoPath = MediaStore.Images.Media.insertImage(
                          getContentResolver(), bitmap, "Img" + timeStamp
                          + ".jpeg", null);
            }
          }
      }
  }
  </code></pre>
  
  <p><code>photoPath</code> value is shown in above.</p>
  
  <p>How can I get my absolute image path from this path.</p>