title: Get contact Details from contactId in android?
body: <p>I am using the following code to fetch the contact details in android using the contact Id. However the code works fine only on android devices version 2.3.5 and not 2.3.3 or versions above 3. Following is my code where contactId is the id of that particular contact. The execution does not move into the <code>if (phone.moveToFirst()) {}</code> part is there some problem in the Query? If so, then why does it work fine on version 2.3.5? Any Help will be appreciated..Thanks</p>
  
  <pre><code>public String queryAllPhoneNumbersForContact(int contactId) 
  {
      String[] projection = new String[] { Phone.NUMBER, Phone.TYPE };
  
      @SuppressWarnings("deprecation")
      Cursor phone = managedQuery(Phone.CONTENT_URI, 
              projection,
              Data.CONTACT_ID + "=?",
              new String[] { String.valueOf(contactId) }, null);
  
      if (phone.moveToFirst())
      {
          int contactNumberColumnIndex = phone.getColumnIndex(Phone.NUMBER);
          int contactTypeColumnIndex = phone.getColumnIndex(Phone.TYPE);
  
          while (!phone.isAfterLast()) 
          {
              String number = phone.getString(contactNumberColumnIndex).trim();
              int type = phone.getInt(contactTypeColumnIndex);
  
              System.out.println("number" + number);
              System.out.println("Type"   + getString(Phone.getTypeLabelResource(type)));
  
              phone.moveToNext();
              if ((getString(Phone.getTypeLabelResource(type)).equals("Mobile"))) 
              {
                  Log.e("WorkNo. : ", number);
                  return number;
              }
          }
      }
      phone.close();
      return null;
  }
  </code></pre>