title: Android dev: SecurityException when READ_CONTACTS
body: <p>I'm new to Android development. Below is what I get when I try to access the contacts.
  Debug log:</p>
  
  <pre><code>... ...
  03-08 17:30:39.622    2330-2330/com.learning.zhanggu.test06 E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.learning.zhanggu.test06, PID: 2330
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.learning.zhanggu.test06/com.learning.zhanggu.test06.Test06}: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{25e387d9 2330:com.learning.zhanggu.test06/u0a58} (pid=2330, uid=10058) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
  ... ...
       Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{25e387d9 2330:com.learning.zhanggu.test06/u0a58} (pid=2330, uid=10058) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
  ... ...
              at android.content.ContentResolver.query(ContentResolver.java:422)
              at com.learning.zhanggu.test06.Test06.fetchContacts(Test06.java:48)
              at com.learning.zhanggu.test06.Test06.onCreate(Test06.java:20)
  ... ...
  </code></pre>
  
  <p>My manifest file:</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.learning.zhanggu.test06" &gt;
      &lt;uses-sdk android:minSdkVersion="8" /&gt;
      &lt;user-permission android:name="android.permission.READ_CONTACTS" /&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".Test06"
              android:label="@string/title_activity_test06" &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>
  
  <p>My Java file:</p>
  
  <pre><code>    public void fetchContacts() {
          StringBuffer output = new StringBuffer();
          Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
          if (cursor.getCount() &gt;0) {
              while (cursor.moveToNext()) {
                  String name = getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                  output.append("Name: "+name+"\n");
              }
              textView1.setText(output);
          }
          cursor.close();
      }
  </code></pre>
  
  <p>Environment:
  Android Studio 1.1.0 on Windows 8.1
  Emulator: Nexus_4_API_19, Nexus_5_API_21</p>
  
  <p>I searched web a bit and tried also to put the permission into the activity registration but got no luck so far.</p>
  
  <p>May anyone kindly advice, thank you very much.</p>