I am trying to get an image from the device gallery and then show it in another action. Code in my activity:
private void startGallery() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, REQ_OPEN_GALLERY) } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQ_OPEN_GALLERY && resultCode == Activity.RESULT_OK) { Uri imageUri = data.getData()
When I try to open uri in another action, I get a SecurityException . Docs says that the permission to receive the uri lasts until the activity that receives them is completed. Therefore, when my activity is finished, I am not allowed to read the file.
Is there any way to extend uri permission to allow other actions to open the file using this uri? Or just a way to copy the image to the local application store?
UPD: My goal is to store the resulting uri in local db and allow other actions and services to read this file.
source share