Android: Access Content Provider from another application
<p>I tried searching stackoverflow.com and tried every answer but none of them  work.</p>

<p>I have a content provider and it was working when the user of the content provider is in the same application. However, I have Permission Denial error when accessing from another application.</p>

<p>LogCat</p>

<pre><code>Caused by: java.lang.SecurityException: Permission Denial: opening provider com.abc.contentprovidersbooks.BooksProvider from ProcessRecord{4174b338 18673:com.abc.contentprovidersuserbooks/u0a10112} (pid=18673, uid=10112) requires com.abc.contentprovidersbooks.READ_DATABASE or com.abc.contentprovidersbooks.WRITE_DATABASE
</code></pre>

<p>Content Provider AndroidManifest:-</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.contentprovidersbooks"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" /&gt;

&lt;application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"&gt;

    &lt;activity
        android:name="com.abc.contentprovidersbooks.ContentProvidersBook"
        android:label="@string/app_name" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;provider android:name="BooksProvider"
        android:authorities="com.abc.contentprovidersbooks.Books"
        android:readPermission="com.abc.contentprovidersbooks.READ_DATABASE"
        android:writePermission="com.abc.contentprovidersbooks.WRITE_DATABASE"
        android:exported="true"&gt;

    &lt;/provider&gt;            
&lt;/application&gt;
</code></pre>

<p></p>

<p>Content Provider User application AndroidManifest:-</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tshouse.contentprovidersuserbooks"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" /&gt;
&lt;uses-permission android:name="com.tshouse.contentprovidersbooks.READ_DATABASE"/&gt;
&lt;uses-permission android:name="com.tshouse.contentprovidersbooks.WRITE_DATABASE"/&gt;

&lt;application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" 
    android:readPermission="com.tshouse.contentprovidersbooks.READ_DATABASE"
    android:writePermission="com.tshouse.contentprovidersbooks.WRITE_DATABASE"
    &gt;
    &lt;activity
        android:name="com.tshouse.contentprovidersbooks.ContentProvidersUserBooks"
        android:label="@string/app_name" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
&lt;/application&gt;
</code></pre>

<p></p>

<p>Please advise how to declare the permission.</p>

<p>Thanks</p>
