title: Permission denial - permissions don't work
body: <p>I'm dealing with a weird permission issue.</p>
  
  <p>I'm trying to read contacts, SMS  and call logs and for that, I'm using these permissions in my Manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_CALL_LOG" /&gt;
  &lt;uses-permission android:name="android.permission.READ_CALL_LOG" /&gt;
  &lt;uses-permission android:name="android.permission.READ_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
  </code></pre>
  
  <p>When I first started to read sms, it worked. Then I tried contacts and I had an error message telling me that I need READ_CONTACTS permission (which I already used). I cleaned the project and then it worked. But now nothing works, be it SMS, contacts or call logs. I cleaned the project, rebuild it, still nothing.</p>
  
  <p>My gradle build:</p>
  
  <pre><code>android {
      compileSdkVersion 23
      buildToolsVersion "22.0.1"
  
      defaultConfig {
          applicationId "com.xyz"
          minSdkVersion 15
          targetSdkVersion 23
          versionCode 1
          versionName "1.0"
      }
  </code></pre>
  
  <p>I don't think the minSdkVerion or compileSdkVersion is a problem, like I said at the beginning SMS reading worked, now it's not even if I remove the call log permission.</p>
  
  <p>Some code lines:</p>
  
  <pre><code>public void backUpContacts() {
      String[] dataContacts = {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone._ID};
      Cursor cursor = this.mContext.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, dataContacts, null, null, null);
      JSONObject jsonContacts;
      JSONArray jsonArray = new JSONArray();
  
      while (cursor != null &amp;&amp; cursor.moveToNext()) {
          jsonContacts = new JSONObject();
          for (int i = 0; i &lt; cursor.getColumnCount(); i++) {
              jsonContacts.put(cursor.getColumnName(i), cursor.getString(i));
          }
          contacts = cursor.getColumnCount();
          jsonArray.add(jsonContacts);
      }
  
  
      Log.d("jsonArray", jsonArray.toString());
      if (cursor != null) cursor.close();
      createFile(jsonArray, "contacts");
  }
  
  public void backupSms() {
      JSONArray listSmsInbox;
      JSONArray listSmsSent;
  
      listSmsInbox = getPhoneSms("content://sms/inbox", "received");
      listSmsSent = getPhoneSms("content://sms/sent", "sent");
  
      Log.i("listSmsInbox", listSmsInbox.toString());
      Log.i("listSmsSent", listSmsSent.toString());
  }
  
  private JSONArray getPhoneSms(String parsing, String param) {
          Cursor c = this.mContext.getContentResolver().query(Uri.parse(parsing), null, null, null, null);
          JSONObject jsonSms = new JSONObject();
          JSONArray jsonArray = new JSONArray();
  
          while (c != null &amp;&amp; c.moveToNext()) {
              jsonSms = new JSONObject();
              for (int i = 0; i &lt; c.getColumnCount(); i++) {
                  jsonSms.put(c.getColumnName(i), c.getString(i));
              }
              jsonArray.add(jsonSms);
  
              if (param.equals("received")) {
                  receivedSms = c.getColumnCount();
              } else {
                  sentSms = c.getColumnCount();
              }
          }
          jsonArray.add(jsonSms);
  
          if (c != null) c.close();
          createFile(jsonArray, param);
  
          return jsonArray;
      }
  </code></pre>
  
  <p>I'm calling these methods with AsyncTask:</p>
  
  <pre><code>@Override
      protected Void doInBackground(Void... params) {
          if (param.equals("contacts")) {
              backUpContent.backUpContacts();
          } else if (param.equals("sms")) {
              backUpContent.backupSms();
          } else if (param.equals("callLogs")) {
              backUpContent.backUpCallLogs();
          }
  
          publishProgress(0);
          return null;
      }
  </code></pre>
  
  <p>Thanks for your help!</p>