dayroma dayroma - 3 months ago 70x
Android Question

Android SecurityException: Permission Denial

I have permission problems in my Android app:
here the log.

06-25 17:25:35.862 12039-13799/? E/DatabaseUtils﹕ Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading uri content://media/external/images/media from pid=1580, uid=10108 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(
at android.content.ContentProvider$Transport.enforceReadPermission(
at android.content.ContentProvider$Transport.query(
at android.content.ContentProviderNative.onTransact(
at android.os.Binder.execTransact(

06-25 17:25:35.870 1580-2997/? E/iu.UploadsManager﹕ Insufficient permissions to access media store
java.lang.SecurityException: Permission Denial: reading uri content://media/external/images/media from pid=1580, uid=10108 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(
at android.database.DatabaseUtils.readExceptionFromParcel(
at android.database.DatabaseUtils.readExceptionFromParcel(
at android.content.ContentProviderProxy.query(
at android.content.ContentResolver.query(
at android.content.ContentResolver.query(
at ifh.i(PG:5904)
at ifh.h(PG:619)
at ifh.<init>(PG:187)
at iel.c(PG:4045)
at gen_binder.root.RootModule$Generated.a(PG:1131)
at nmw.e(PG:415)
at nmw.b(PG:242)
at nmw.a(PG:207)
at nmw.a(PG:493)
at ier.a(PG:2195)
at ier.onPerformSync(PG:125)
at android.content.AbstractThreadedSyncAdapter$

06-25 17:24:37.031 1580-1611/? E/GooglePlusContactsSync﹕ Failed to clear out contacts
java.lang.SecurityException: Permission Denial: opening provider from ProcessRecord{9557af9} (pid=1580, uid=10108) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
at android.os.Parcel.readException(
at android.os.Parcel.readException(
at android.content.ContentResolver.acquireUnstableProvider(
at android.content.ContentResolver.query(
at android.content.ContentResolver.query(
at dpm.a(PG:397)
at dpm.b(PG:1345)

I know it's a permissions problem and I could solve with grant permission like this:

// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
!= PackageManager.PERMISSION_GRANTED) {

// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {

// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.

} else {

// No explanation needed, we can request the permission.

new String[]{Manifest.permission.READ_CONTACTS},

// app-defined int constant. The callback method gets the
// result of the request.

and then using this to set permission to my providers:

public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {

// permission was granted, yay! Do the
// contacts-related task you need to do.

} else {

// permission denied, boo! Disable the
// functionality that depends on this permission.

// other 'case' lines to check for other
// permissions this app might request

The problem is that I don't know in what part of my project I have to put this permission request:
I'm using Auth0 Custom UI autenthication for login, Mysqlite as internal database and GoogleCards for a ListView.

Can you help me to understand how to grant this Permission Denial?

Thank you very much


well I would recommend using Ask, its a permission helper library.

Using this you won't have to write so much code, just two lines will get the things done for you.

Here is the usage details

First compile the dependency in your build.gradle

dependencies {
    compile 'com.vistrav:ask:2.4'

and then in the start of the activity in OnCreate or on any button press you can ask permission like this


and thats it.

You can find more information here. I am using it in almost all my projects and its simple and easy.

Hope it helps