MineConsulting SRL
MineConsulting SRL

Reputation: 2340

android - make content provider available to one package only

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

Answers (2)

Sandeep Dude
Sandeep Dude

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

David Wasser
David Wasser

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

Related Questions