title: Permission denial while accessing content provider of another application
body: <p>Tutorial I am using for understanding Content Providers</p>
  
  <blockquote>
    <p>AppA: <a href="https://www.tutorialspoint.com/android/android_content_providers.htm" rel="nofollow noreferrer">https://www.tutorialspoint.com/android/android_content_providers.htm</a></p>
  </blockquote>
  
  <p>I have created another application which I intend to use, to access the Content Provider of the tutorial application</p>
  
  <blockquote>
    <p>AppB Manifest </p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.MyApplication2"&gt;
      &lt;uses-permission android:name="com.example.MyApplication.StudentProvider.READ_PERMISSION"/&gt;
      &lt;uses-permission android:name="com.example.MyApplication.StudentProvider.WRITE_PERMISSION"/&gt;
      &lt;uses-permission android:name="android.permission.READ_USER_DICTIONARY"/&gt;
      &lt;uses-permission android:name="android.permission.permRead"/&gt;
  
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&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;
  &lt;/manifest&gt;
  </code></pre>
  
  <blockquote>
    <p>AppB Partial Code:</p>
  </blockquote>
  
  <pre><code>String URL = "content://com.example.MyApplication.StudentsProvider/students";
  
  Uri uri = Uri.parse(URL);
  
  Cursor c = getContentResolver().query(uri,null,null,null,null);
  
  
  String _ID = "_id";
  String NAME = "name";
  String GRADE = "grade";
  
  if (c.moveToFirst()) {
      do{
          Toast.makeText(this,
                  c.getString(c.getColumnIndex(_ID)) +
                          ", " +  c.getString(c.getColumnIndex(NAME)) +
                          ", " + c.getString(c.getColumnIndex(GRADE)),
                  Toast.LENGTH_SHORT).show();
      } while (c.moveToNext());
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <blockquote>
    <p><a href="https://pastebin.com/NejEJYeV" rel="nofollow noreferrer">Caused by: java.lang.SecurityException: Permission Denial: opening provider</a></p>
  </blockquote>
  
  <p>Any ideas as to why I am getting this error? Any help is appreciated!</p>
  
  <p><strong>EDIT:</strong> I got the Solution! (<em>//This line is new</em> <strong>&amp;</strong> <em>//Line modified</em>) </p>
  
  <pre><code>String URL = "content://com.example.MyApplication.StudentsProvider/students";
  Uri uri = Uri.parse(URL);
  ContentResolver cr = getContentResolver(); //This line is new
  Cursor c = cr.query(uri,null,null,null,null); //Line modified
  
  String _ID = "_id";
  String NAME = "name";
  String GRADE = "grade";
  
  if (c.moveToFirst()) {
  do{
      Toast.makeText(this,
              c.getString(c.getColumnIndex(_ID)) +
                      ", " +  c.getString(c.getColumnIndex(NAME)) +
                      ", " + c.getString(c.getColumnIndex(GRADE)),
              Toast.LENGTH_SHORT).show();
  } while (c.moveToNext());
  }
  </code></pre>
  
  <p>Now my AppB is able to read the ContentProvider from AppA, however I still do not understand why this should make a difference! </p>
  
  <p><strong>EDIT2:</strong> Already replaced the tutorial Manifest with <a href="https://pastebin.com/Kv5nGjsg" rel="nofollow noreferrer">ChangedManifest XML</a></p>