title: Delete SMS from sent list in android
body: <p>I am developing android app. I need to delete the SMS sent as soon as it is sent. I tried using following piece of code to delete the SMS but the sent box still shows this message in list, although it does not open up up when clicked.</p>
  
  <pre><code>public void sendSMS(View view){
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage("9XXXXXXXXX2", null, "CON", null, null);       
      Uri sentURI = Uri.parse("content://sms/sent/");                                 
      String[] reqCols = new String[] { "thread_id","_id", "address", "body" };
      ContentResolver cr = getContentResolver();                                  
      Cursor cursor = cr.query(sentURI, reqCols, null, null, null);
      //Cursor cursor = cr.query(sentURI, reqCols, "address like ?", new String[]{"9673479788"}, null);
      String id =null;
      String thread_id =null;
      long threadId=0;
      int count;
      if (cursor != null) {
          try {
                count = cursor.getCount();
                if (count &gt; 0) {
                  cursor.moveToFirst();
                  threadId = cursor.getInt(1);                      
                  System.out.println("\n THREADID : "+String.valueOf(threadId));
                  Uri thread = Uri.parse("content://sms/sent/" + threadId);
                  //Uri thread = Uri.parse("content://sms/sent/" + threadId);
                  getContentResolver().delete(thread, null, null);
                } else{
                    System.out.println("\n NOTHING DELETED");
              }
          } finally {
                    cursor.close();
          }
      }
      System.out.println("\n THREADID : "+St`enter code here`ring.valueOf(threadId));
  }
  </code></pre>
  
  <p>I can still see the message in the sent box, although it does not open when clicked. Please help. Need to delete from the list of sent sms.</p>