title: Android Telephony.Sms API read/write/delete all SMS records not just Sent and Inbox
body: <p>Working on an Android app that retreives SMS messages on the device using this code;</p>
  
  <pre><code>    public void refreshSmsSent() {
      ContentResolver contentResolver = getContentResolver();
      arrayAdapter.clear();
      Cursor c = contentResolver.query(Telephony.Sms.Sent.CONTENT_URI, // Official CONTENT_URI from docs
              new String[] { Telephony.Sms.Sent.ADDRESS, Telephony.Sms.Sent.BODY, Telephony.Sms.Sent._ID, Telephony.Sms.Sent.ERROR_CODE, Telephony.Sms.Sent.TYPE }, // Select body text
              null,
              null,
              Telephony.Sms.Sent.DEFAULT_SORT_ORDER); // Default sort order
      int totalSMS = c.getCount();
      if (c.moveToFirst()) {
          for (int i = 0; i &lt; totalSMS; i++) {
              String str = "To: " + c.getString(0) +
                      "\n" + c.getString(1) + "\n" + c.getString(2) + "\n" + c.getString(3) + "\n" + c.getString(4) + "\n";
              arrayAdapter.add(str);
              c.moveToNext();
          }
      } else {
      Toast.makeText(this, "Nothing here..!", Toast.LENGTH_SHORT).show();
      }
      c.close();
  }
  </code></pre>
  
  <p>This works absolutely fine for <code>Telephony.Sms.Sent</code> and <code>Telephony.Sms.Inbox</code> but I can't seem to get anything back using the same code with <code>Telephony.Sms.Outbox</code> or <code>Telephony.Sms.Draft</code></p>
  
  <p>I think I have the required permissions in place in the manifest;</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.READ_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
  </code></pre>
  
  <p>Question: 
  Ideally, I'd like to get all SMS records on the device and process (e.g. delete, resend) each one in my own code... is there a method I can use to retrieve all SMS messages on the device in one go using a single query..?</p>
  
  <p>A day later... some progress... this code using <code>Telephony.Sms</code> gets all Sent and Inbox entries in single query...</p>
  
  <pre><code>    public void refreshSmsAll() {
      ContentResolver contentResolver = getContentResolver();
      arrayAdapter.clear();
      Cursor c = contentResolver.query(Telephony.Sms.CONTENT_URI, // Official CONTENT_URI from docs
              new String[] { Telephony.Sms.ADDRESS, Telephony.Sms.BODY, Telephony.Sms.TYPE, Telephony.Sms.ERROR_CODE, Telephony.Sms._ID }, // Select body text
              null,
              null,
              Telephony.Sms.Draft.DEFAULT_SORT_ORDER); // Default sort order
      int totalSMS = c.getCount();
      if (c.moveToFirst()) {
          for (int i = 0; i &lt; totalSMS; i++) {
              String str = "X: " + c.getString(0) +
                      "\n" + c.getString(1) + "\n" + c.getString(2) + "\n" + c.getString(3) + "\n" + c.getString(4) + "\n";
              arrayAdapter.add(str);
              c.moveToNext();
          }
      } else {
  Toast.makeText(this, "Nothing here..!", Toast.LENGTH_SHORT).show();
      }
      c.close();
  }
  </code></pre>
  
  <p>However, what it doesn't get is Outbox and Draft... any ideas, anyone..?</p>
  
  <p>Another 2hrs later... getting somewhere with the delete now...</p>
  
  <pre><code>    public void onDeleteMsg(View view) {
      ContentResolver contentResolver = getContentResolver();
      boolean isSmsDeleted = false;
      try {
          contentResolver.delete(Telephony.Sms.CONTENT_URI, "_id=?",new String[] { "371" });
          isSmsDeleted = true;
          Toast.makeText(this, "Deleted..!", Toast.LENGTH_SHORT).show();
      } catch (Exception ex) {
          isSmsDeleted = false;
          Toast.makeText(this, "NOT Deleted..!", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>Only works if my sms app is the default, which is fine, so that means I have to insert and delete messages in the sms database myself..!</p>
  
  <pre><code>    public void onInsertMsg(View view) {
      ContentResolver contentResolver = getContentResolver();
      ContentValues values = new ContentValues();
      values.put(Telephony.Sms.ADDRESS, "123456789");
      values.put(Telephony.Sms.BODY, "The message");
      values.put(Telephony.Sms.TYPE, "2");
      boolean isSmsDeleted = false;
      try {
          contentResolver.insert(Telephony.Sms.CONTENT_URI,values);
          Toast.makeText(this, "Inserted..!", Toast.LENGTH_SHORT).show();
      } catch (Exception ex) {
          Toast.makeText(this, "NOT Inserted..!", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>Scenario: 
  Along with plenty of received/sent sms, I've created a draft message and forced a failed message to a dud number, neither of which appear in any query.</p>
  
  <p>Interestingly, if I force a manual re-send on the failed message it appears in the Sent query for the duration of the re-try, then it isn't present.</p>
  
  <p>I'm assuming that anything I can see in the standard messaging app for the device should be available to my "home-made" app, understanding that there may be some limitations depending on which one is the default SMS app.</p>