Question: I'm trying to get image from gallery. 

```
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select picture"), resultCode );

```

After I returned from this activity I have a data, which contains Uri. It looks like:

```
content://media/external/images/1

```

How can I convert this path to real one (just like '`/sdcard/image.png`') ?

Thanks

Answer: 
**EDIT:**
Use this Solution here: <https://stackoverflow.com/a/20559175/2033223>
Works perfect!

First of, thank for your solution @luizfelipetx

I changed your solution a little bit. This works for me:

```
public static String getRealPathFromDocumentUri(Context context, Uri uri){
    String filePath = "";

    Pattern p = Pattern.compile("(\\d+)$");
    Matcher m = p.matcher(uri.toString());
    if (!m.find()) {
        Log.e(ImageConverter.class.getSimpleName(), "ID for requested image not found: " + uri.toString());
        return filePath;
    }
    String imgId = m.group();

    String[] column = { MediaStore.Images.Media.DATA };
    String sel = MediaStore.Images.Media._ID + "=?";

    Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            column, sel, new String[]{ imgId }, null);

    int columnIndex = cursor.getColumnIndex(column[0]);

    if (cursor.moveToFirst()) {
        filePath = cursor.getString(columnIndex);
    }
    cursor.close();

    return filePath;
}

```

Note: So we got documents and image, depending, if the image comes from 'recents', 'gallery' or what ever. So I extract the image ID first before looking it up.
This helped me to get uri from Gallery and convert to a file for Multipart upload

```
File file = FileUtils.getFile(this, fileUri);

```

<https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java>