I made an onActivityResult to get a URI for the file I selected in the media store
Uri selectedImage = data.getData();
If you change this to String,
content://media/external/images/media/47
or /external/images/media/47
when used as the path But is there any way to know this as an absolute path?Because I want to copy the image to the place I followed, and if it's numbered in the URI, the numbering will change when the device is turned off and on...
Absolute path is
public String getRealPathFromURI(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();
}
}
}
If you do this, you can change it.
© 2024 OneMinuteCode. All rights reserved.