title: How to get phone number type label from given phone number in android
body: <p>I tried to print Contact name(Eg. "Jose") &amp; Contact phone number type value(Eg. "Home","Work",etc.,) from phone contact for given particular phone number(Eg. "9600515852")</p>
  
  <p>for this i used bellow code. but i can able get Contact name only. i am getting app crash when i am trying to get the phone number type.</p>
  
  <p>Please guide me.</p>
  
  <pre><code>String number = getContactName(this, "9600515852");
  Toast.makeText(getApplicationContext(),number,Toast.LENGTH_LONG).show();
  
  private String getContactName(Context context, String number) {
  String TAG ="" ;
  String name = null, label=null;
  int type=0;
  
  // define the columns I want the query to return
  String[] projection = new String[] { ContactsContract.PhoneLookup.DISPLAY_NAME,ContactsContract.PhoneLookup._ID };
  
  // encode the phone number and build the filter URI
     Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
  
  // query time
  Cursor cursor = context.getContentResolver().query(contactUri, projection, null, null, null);
  
          if(cursor != null) {
              if (cursor.moveToFirst()) {
                  name =      cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
                 // type = cursor.getInt(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
              } else {
                  Log.v(TAG, "Contact Not Found @ " + number);
              }
              cursor.close();
          }
          return name+" - "+number;
      }
  </code></pre>