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.
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.