skip to Main Content

I am using local database ROOM to store some uri from phone but I can’t reload it in the second times.

The exception is:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.andiogame, PID: 2878
java.lang.SecurityException: com.example.andiogame has no access to content://media/external/images/media/24
    at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)

The code is:

Uri uri = Uri.parse(simpleMessage.getUri());
imageView.setImageURI(uri);

2

Answers


  1. Try this

    Uri uri = Uri.parse(simpleMessage.getUri());
    imageView.setImageURI(null); 
    imageView.setImageURI(uri);
    
    Login or Signup to reply.
  2. Did you declare permission to read external storage.

        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    

    Also, if you’re targeting Android 23+ (which you probably are), you need to ask for permissions at runtime.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search