title: How to delete particular inbox message in Android version 5.0 lollipop or in Kitkat?
body: <p>I am making to delete particular sms of phone number task. when I am testing in motog or Android version 5.0's mobile. I can't delete particular number's sms. My code snippet is below.</p>
  
  <pre><code>public void deleteSMS(Context context,String number) {
      try {
          Log.d("","Deleting SMS from inbox");
          Uri uriSms = Uri.parse("content://sms/inbox");
          Cursor c = context.getContentResolver().query(uriSms,
                  new String[] { "_id", "thread_id", "address",
                          "person", "date", "body" }, "address = '"+number+"'", null, null);
  
          if (c != null &amp;&amp; c.moveToFirst()) {
              do {
                  long id = c.getLong(0);
                  long threadId = c.getLong(1);
                  String address = c.getString(2);
                  String body = c.getString(5);
                  Toast.makeText(getApplicationContext(),"SMS with id: " + threadId +" Number:- " +address,Toast.LENGTH_LONG).show();
                  Log.d("", "SMS with id: " + threadId +" Number:- " +address);
                  if ( address.equals(number)) {
                      Log.d("", "Deleting SMS with id: " + threadId);
                      context.getContentResolver().delete(
                              Uri.parse("content://sms/" + id), null, null);
                  }
              } while (c.moveToNext());
          }
      } catch (Exception e) {
          Toast.makeText(getApplicationContext(),"Could not delete SMS from inbox ",Toast.LENGTH_LONG).show();
          Log.e("", "Could not delete SMS from inbox: " + e.getMessage());
      }
  }
  </code></pre>