Sharing files through Intents (part 2): fixing the permissions before Lollipop

Lorenzo Quiroli
Feb 20, 2017 · 5 min read
02-16 05:41:07.477 8063-8063/ E/AndroidRuntime: FATAL EXCEPTION: main
Process:, PID: 8063
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(
at android.view.View.performClick(
at android.view.View$
at android.os.Handler.handleCallback(
Caused by: java.lang.SecurityException: Permission Denial: opening provider from ProcessRecord{9d5abad8} (pid=8063, uid=10031) that is not exported from uid 10057
at android.os.Parcel.readException(
at android.os.Parcel.readException(
at android.content.ContentResolver.acquireUnstableProvider(
at android.content.ContentResolver.openAssetFileDescriptor(
at android.content.ContentResolver.openOutputStream(
at android.content.ContentResolver.openOutputStream(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(

The bad solution

context.grantUriPermission(String toPackage, Uri uri, int flags);
context.revokeUriPermission(Uri uri, int modeFlags);

Going deeper

How can we fix it in previous versions?

Why are we including Lollipop?

Wrapping up

Thanks to Roberto Orgiu

Lorenzo Quiroli

Written by

Android Engineer @ busuu

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade