title: Android app crash on start - SecurityException
body: <p>As I click the application 
  Unfortunately,App has Stopped.</p>
  
  <p>I don't know how to solve this error in Android Studio please help me out of this  </p>
  
  <p>This is the code to display inbox sms </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  ListView lv;
  Cursor cr;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      dip();
  }
  public void dip(){
      lv=(ListView)findViewById(R.id.ls);
      ArrayList&lt;String&gt; s;
      s = readAllData();
      String ms="";
      for (int i=0;i&lt;s.size();i++) {
          ms+=s.get(i)+",";
      }
      String messageArray[];
      messageArray=ms.split(",");
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;&gt;(this,android.R.layout.simple_list_item_1,android.R.id.text1,messageArray);
      lv.setAdapter(adapter);
      lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
          }
      });
  }
  public ArrayList&lt;String&gt; readAllData() {
      ArrayList&lt;String&gt; sms = new ArrayList&lt;&gt;();
      Uri us = Uri.parse("content://sms/inbox");
      cr = getContentResolver().query(us, null, null, null, null);
      assert cr != null;
      cr.moveToFirst();
      while (cr.moveToNext()) {
          String body = cr.getString(cr.getColumnIndexOrThrow("body"));
          sms.add(body);
      }
      return sms;
  }
  </code></pre>
  
  <p>and here is the LogCat Exceptions</p>
  
  <pre><code>D/AndroidRuntime: Shutting down VM
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime: Process: example.prathik.com.myapplication, PID: 12003
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{example.prathik.com.myapplication/example.prathik.com.myapplication.MainActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=12003, uid=10058 requires android.permission.READ_SMS, or grantUriPermission()
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:  Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=12003, uid=10058 requires android.permission.READ_SMS, or grantUriPermission()
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.os.Parcel.readException(Parcel.java:1599)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.content.ContentResolver.query(ContentResolver.java:491)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.content.ContentResolver.query(ContentResolver.java:434)
   12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at example.prathik.com.myapplication.MainActivity.readAllData(MainActivity.java:51)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at example.prathik.com.myapplication.MainActivity.dip(MainActivity.java:32)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at example.prathik.com.myapplication.MainActivity.onCreate(MainActivity.java:26)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
  12-29 12:24:03.876 12003-12003/example.prathik.com.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method
  </code></pre>