Skip to content

Instantly share code, notes, and snippets.

@mistrydarshan99
Created August 27, 2014 20:08
Show Gist options
  • Save mistrydarshan99/117265fbf5a0213b1170 to your computer and use it in GitHub Desktop.
Save mistrydarshan99/117265fbf5a0213b1170 to your computer and use it in GitHub Desktop.
Get image path taken from camera
public Uri getImageUri(Context inContext, Bitmap inImage) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
return Uri.parse(path);
}
private String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(uri, projection, null, null,null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment