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.
I am able to display image on screen, but unable to get absolute image path.
I am getting path like:
content://media/external/images/media/1220 content://media/external/images/media/1221 How can I get actual image path?
Here is my 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 && !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 && 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); } } } } photoPath value is shown in above.
How can I get my absolute image path from this path.