title: Getting phone number in inbox/outbox
body: <p>I am currently using</p>
  
  <pre><code>ContentResolver cr = getContentResolver();
  Uri uri = Uri.parse("content://sms/");
  Cursor messagesCursor = cr.query(uri, new String[] { "_id", "address", "body", "person" }, null, null, null);
  
  if (messagesCursor.getCount() &gt; 0) {
      while (messagesCursor.moveToNext()) {
          colName = getContactName(messagesCursor.getString(messagesCursor.getColumnIndex("address"))) + "\n";
      }
  }
  </code></pre>
  
  <p>to get all the text in the user's inbox. From there, <code>messagesCursor.getColumnIndex("address")</code> will get the SMS's number. Then it will be place in <code>getContactName()</code> where it will then get the contacts' name from their contact's list.</p>
  
  <p>This method will take a long time as it goes though EVERY SINGLE text message, get number, then get the contact's name, check if name exist in array, if it doesn't put in array then from there create a ListView.</p>
  
  <p>The app will take a long time to load on start up if the user's inbox contains lots of text.</p>
  
  <p>Is there any special way to get UNIQUE numbers from inbox? Something in <code>cr.query</code>?</p>
  
  <p>Thanks in advance.(:</p>
  
  <hr>
  
  <p><strong>EDIT :</strong></p>
  
  <p>I'm creating just a simple inbox application. It reads from the original inbox message and list the messages in it.</p>
  
  <p>For this project, what I did was to read through ALL the "address" which is the phone number, put it in an ArrayList, and finally to the ListView. As it cycles through all the messages in inbox, it takes a long time to startup.</p>
  
  <p>For example :</p>
  
  <p><em>Inbox Messages</em></p>
  
  <ul>
  <li><p>Person 1</p>
  
  <p>Person 1</p>
  
  <p>Person 1</p>
  
  <p>Person 2</p>
  
  <p>Person 2</p>
  
  <p>Person 3</p>
  
  <p>Person 3</p>
  
  <p>Person 3</p>
  
  <p>Person 3</p></li>
  </ul>
  
  <hr>
  
  <p><strong>What my current code does :</strong></p>
  
  <p>Read EVERY SINGLE message</p>
  
  <p>Check if name in ArrayList</p>
  
  <p>If it is, skip. If not, add in array.</p>
  
  <p>Throw ArrayList into ListView.</p>
  
  <hr>
  
  <p><strong>What my intention was :</strong></p>
  
  <p>A code that only reads out :</p>
  
  <p>Person 1</p>
  
  <p>Person 2</p>
  
  <p>Person 3</p>