android - Get filename and path from URI from mediastore -


I have a onActivityResult returning from a mediastore image selection, which I can call for an image You can get the URLR using the following:

  Ury selected Image = data.getData ();  

It converts it to string:

  content: // media / external / images / media / 47  

or gives a path:

  / external / picture / media / 47  

However I find a way to convert I can not seem to have it in a full path, because I want to load the image in bitmap without copying it elsewhere. I know that this can be done using URI and content resolver, but it breaks on the phone's reboot, I think that MediaStore does not keep its numbering between reboots.

  public string getRealPathFromURI (reference references, Ure content Yuri) {cursor cursor = null; Try {string [] proj = {MediaStore.Images.Media.DATA}; Cursor = context.getContentResolver (). Query (contentUri, proj, null, null, null); Int column_index = cursor.getColumnIndexOrThrow (MediaStore.images.Media.DATA); Cursor.moveToFirst (); Return cursor .getString (column_index); } Finally {if (cursor! = Null) {cursor.close (); }}}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -