Reputation: 2340
is there any way to make an external content provider available to only one package? for example available only to my app? Thanks in advance.
Upvotes: 2
Views: 636
Reputation: 21
Although its too late, I would like to share the answer which I have found, You need to declare your own custom permission inside manifest file of content provider application like this..
<permission android:name= "com.android.testpermission" android:protectionLevel="signature" >
And inside your Content Provider tag you have to specify a permission that a client is required to have like this way...
<provider android:name=".MyProvider"
android:authorities="com.example.contentproviderexample.MyProvider" android:exported="true" android:permission="com.android.testpermission" android:multiprocess="true" ></provider>
And inside your 2nd application to access content provider data you need to specify the uses permission inside manifest file,like this..
<uses-permission android:name="com.android.testpermission"/>
Now sign both the application using same keystore signature & this way any other application can't access your content provider data. Only applications that hold those permissions & signed with same keystore signature will be able to access the provider data.
Upvotes: 2
Reputation: 95578
You can add permissions to the manifest declaration for the content provider. Only applications that hold those permissions will be able to access the provider.
Upvotes: 0