My application allows the user to view some selected images from the gallery or other places. I request Uri images via:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, PickerFragment.PICK_PHOTO);
And then get Uri in onActivityResult (int requestCode, int resultCode, Intent data) and access these images to put them in my applications via:
Uri imageUri= data.getData();
When the application ends, I save all the Uri in my database as strings:
String imageUriString = imageUri.toString();
saveToDB (imageUriString);
However, when I restart the application and restore all Uri from my database with:
String imageUriString = restoreFromDB ();
imageUri = Uri.parse (imageUriString);
the app no longer has rights for these Uri in Android 7.1. I view images through:
ContentResolver cr = mContext.getContentResolver();
InputStream is = cr.openInputStream(imageUri);
BitmapFactory.decodeStream(is, null, o);
But get this exception:
java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord
?
, .
, , .
PS , Uri - , . , , .
PPS , Camera and External Storage, .