Search code examples
androidandroid-contentproviderandroid-permissions

Custom content provider access from another app


I have two apps. one of the two has a custom content provider which works like a charm.

APP A -> The one with the provider

APP B -> The one that needs the data from the provider

Everything works fine in this scenario:

1st : Install app A

2nd: Install app B

However when I do it like this:

1st: Install app B

2nd: Install app A

I get the error :

09-19 13:07:22.576: E/AndroidRuntime(14621): Caused by: java.lang.SecurityException: Permission Denial: opening provider 
uk.co.ringsizer.ui.BirthProvider from ProcessRecord{450c14c8 14621:uk.co.gemtv/u0a360} 
(pid=14621, uid=10360) requires com.eir.provider.Size.READ_DATABASE 
or com.eir.provider.Size.WRITE_DATABASE

My permissions are clearly stated in the manifest file and they are correct since it works if I install the apps in a different order.

It's the first time I'm using Content provider and I am relatively new to Android so the problem might be obvious to more experienced developers.

Any ideas? Has anybody else experienced the same issue before?

Thanks in advance.


Solution

  • The app that defines the custom <permission> must be installed before the app that requests it via <uses-permission>. If they are installed in the wrong order, the <uses-permission> app does not get the permission and must be uninstalled and reinstalled.

    Custom permissions in general are risky for SDK apps.