title: How to delete an SMS of the phone inbox from an application on Android
body: <p>I am getting the error:</p>
  
  <pre><code>Permission Denial:writing`com.android.provider.telephony.smsprovider uri content://sms/472 from pid=11211, uid=10142 requires
  android.permission.write_sms, or granturipermission()
  </code></pre>
  
  <p>Please help me to solve this as I'm new for this.</p>
  
  <p>My code is:</p>
  
  <pre><code>public void deleteSMS()
  {
      Uri inboxUri = Uri.parse("content://sms/inbox");
      int count = 0;
      Cursor c = getContentResolver().query(inboxUri , null, null, null, null);
      while (c.moveToNext()) {
          try {
              // Delete the SMS
              String pid = c.getString(0); // Get id;
              String uri = "content://sms/" + pid;
              count =getContentResolver().delete(Uri.parse(uri),
                      null, null);
              Toast.makeText(getApplicationContext(),"message deleted successfully..!"+count, 5000).show();
          } catch (Exception e) {
              Toast.makeText(getApplicationContext(), e.toString(), 5000).show();
          }
      }}
  
  Added Permission in manifest file:
  
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_SMS"/&gt;
  &lt;uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;receiver android:name=".receiver.SMSReceiver" android:enabled="true"&gt;
      &lt;intent-filter android:priority="1000"&gt;
          &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;
      &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>I added all permissions, but I am still not getting an answer and the same error is displayed...</p>