views:

624

answers:

1

Hi,

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

+1  A: 

You can find a code example here

However, is it really necessary for you to get a physical path? For example, ImageView.setImageUri() and ContentResolver.openInputStream() allow you to access the contents of a file without knowing its real path.

molnarm
Its exactly what I've looked for, but couldn't find. Thanks.
davs
if http://www.androidsnippets.info/snippets/130/ doesn't work, try http://www.androidsnippets.org/snippets/130/
davs