Thursday, May 5, 2016

Security Exception accessing Content Provider in another application

Hello everybody!

I'm trying to create a content provider usable only by the applications that are signed by the same certificate. I've declared the content provider like this

<provider
android:name=".MyProvider"
android:authorities="com.example.provider"
android:permission="com.example.permissions.USER_P ERMISSION"
android:readPermission="com.example.permissions.US ER_PERMISSION_READ"
android:writePermission="com.example.permissions.U SER_PERMISSION_WRITE"
android:exported="true">
</provider>
I have declared the permissions with signature protection level.

All good but when I try to access the provider from the other application like this:

//Create an URI that will be used to check the status of the content provider
Uri myURI = Uri.parse("http://ift.tt/21zgI7M;);
ContentResolver contentResolver = getContentResolver();

try {
contentResolver.insert(prototypeURI,null);
} catch (Exception e) {
e.printStackTrace();
}
I get a SecurityException: Permission Denial: opening provide ... requires com.example.permissions.USER_PERMISSION_READ.

Any ideas?


from xda-developers http://ift.tt/24tbAYc
via IFTTT

No comments:

Post a Comment