title: how to get the contact infomation by sms message
body: <p>I'm working on an extend SMS application. And now i can read all the SMS message from the mmssms.db. In the SMS database table, the field 'person' indicate the '_id' in contact table. When 'person' is >= 1, that means the message is sent from people in the contact list. So i can 'managedQuery' from contact table. But the question is, in my mobile phone, the test program sometimes can NOT query the contact infomation even 'person' >= 1.  So can somebody show me some correct ways to query contact infomation by 'person' filed in SMS table ?
  Here is some sample code which can make my question more clear:</p>
  
  <pre><code>class ContactItem {  
      public String mName;  
  }  
  
      ContactItem getContact(Activity activity, final SMSItem sms) {  
          if(sms.mPerson == 0) return null;  
          Cursor cur = activity.managedQuery(ContactsContract.Contacts.CONTENT_URI,   
                  new String[] {PhoneLookup.DISPLAY_NAME},   
                  " _id=?",   
                 new String[] {String.valueOf(sms.mPerson)}, null);  
         if(cur != null &amp;&amp;  
             cur.moveToFirst()) {  
             int idx = cur.getColumnIndex(PhoneLookup.DISPLAY_NAME);  
             ContactItem item = new ContactItem();  
             item.mName = cur.getString(idx);  
             return item;  
         }  
         return null;  
     }  
  </code></pre>