Last active
December 28, 2015 16:09
-
-
Save dafi/7527494 to your computer and use it in GitHub Desktop.
android - Working with MediaStore to share image from buffer and obtain the uri real path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getRealPathFromImageURI(Context context, Uri contentUri) { | |
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(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment