for example
real path is mnt/sdcard/image_1.jpg Uri path is content://media/external/images/media/140 like this
Uri photoUri =Uri.parse("content://media/external/images/media/140");
Log.d("selectedphoto",""+photoUri);
selectedImagePath = getPath(photoUri);
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
In above code I convert Uri to real path but dnt know how to convert real path to Uri
Try this:
Uri.fromFile(new File("/sdcard/cats.jpg"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With