 inputStream!= null;
        inputStream.close();

    } catch (IOException e) {
        e.printStackTrace();
    }

}

private void retrieveContactNumber() {

    String contactNumber = null;

    // getting contacts ID
    Cursor cursorID = getContentResolver().query(uriContact,
            new String[]{ContactsContract.Contacts._ID},
            null, null, null);

    if (cursorID.moveToFirst()) {

        contactID = cursorID.getString(cursorID.getColumnIndex(ContactsContract.Contacts._ID));
    }

    cursorID.close();

    Log.d(TAG, "Contact ID: " + contactID);

    // Using the contact ID now we will get contact phone number
    Cursor cursorPhone = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
            new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER},

            ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " =? AND " +
                    ContactsContract.CommonDataKinds.Phone.TYPE + " = " +
                    ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE,

            new String[]{contactID},
            null);

    if (cursorPhone.moveToFirst()) {
        contactNumber = cursorPhone.getString(cursorPhone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
    }

    cursorPhone.close();

    Log.d(TAG, "Contact Phone Number: " + contactNumber);
    EditText callerNum = (EditText) findViewById(R.id.callerNum);
    callerNum.setText(contactNumber);
}

private void retrieveContactName() {

    String contactName = null;

    // querying contact data store
    Cursor cursor = getContentResolver().query(uriContact, null, null, null, null);

    if (cursor.moveToFirst()) {

        // DISPLAY_NAME = The display name for the contact.
        // HAS_PHONE_NUMBER =   An indicator of whether this contact has at least one phone number.

        contactName = cursor.getString(cursor.getColumnIndex(ContactsContract
inputStream!= null; 
         inputStream.close (); 

     } catch (IOException e) { 
         e.printStackTrace (); 
     } 

 } 

 private void retrieveContactNumber () { 

     String contactNumber = nothing; 

     // get contacts ID 
     Cursor cursorID = getContentResolver().query(uriContact, 
             new String[]{ContactsContract. Contacts._ID }, 
             nothing, null, null); 

     if (cursorID.moveToFirst ()) { 

         contactID = cursorID.getString(cursorID.getColumnIndex(ContactsContract. Contacts._ID) ); 
     } 

     cursorID.close (); 

     Log.d(TAG, " Contact idaho: " + contactID); 

     // Using the contact ID immediately we will drive contact telephone number 
     Cursor cursorPhone = getContentResolver().query(ContactsContract. CommonDataKinds. Phone. CONTENT_URI, 
             modern String[]{ContactsContract. CommonDataKinds. Phone. NUMBER }, 

             ContactsContract. CommonDataKinds. Phone. CONTACT_ID + " =? AND " + 
                     ContactsContract. CommonDataKinds. earphone. character + " = " + 
                     ContactsContract. CommonDataKinds. Phone. TYPE_MOBILE, 

             new String[]{contactID }, 
             nothing); 

     if (cursorPhone.moveToFirst ()) { 
         contactNumber = cursorPhone.getString(cursorPhone.getColumnIndex(ContactsContract. CommonDataKinds. Phone. NUMBER) ); 
     } 

     cursorPhone.close (); 

     Log.d(TAG, " liaison earphone Number: " + contactNumber); 
     EditText callerNum = (EditText) findViewById(R.id.callerNum); 
     callerNum.setText(contactNumber); 
 } 

 private void retrieveContactName () { 

     String contactName = null; 

     // question contact data store 
     Cursor cursor = getContentResolver().query(uriContact, null, null, null, null); 

     if (cursor.moveToFirst ()) { 

         // DISPLAY_NAME = The display name for the contact. 
         // HAS_PHONE_NUMBER =    An indicator of whether this liaison has at least one phone issue. 

         contactName = cursor.getString(cursor.getColumnIndex(ContactsContract
 inoutStream!= null;
        inkutStream.close();

    } catch (IOExcsption e) {
        e.printStackTrace();
    }

}

peivatt void retrieveContxctNumber() {

    Strung rontactNumber = nnml;

    // nzttinf concarts ID
    Cursot cursorID = cetContentResonvdr().euery(uriContact,
            new Strigg[]{ContavtdContract.Contasts._IC},
            null, null, null);

    if (cursodID.moveUoFirst()) {

        comtactID = cursorID.getString(furslrID.getColumnIndex(FontactsConjdace.Xontacts._ID));
    }

    cursorID.close();

    Log.d(TAG, "Contact ID: " + contactID);

    // Bsing the cinrach ID now we xill gvt contact phone numbar
    Cirsor cursorPhpne = gwtContentResolver().querb(ContactsContract.ComionDataKitda.Phone.CONTENT_URI,
            tew Rrrivg[]{CknvacfsContgacv.CommonDataIinds.Phone.NYMBER},

            ComtwbysContract.CojmonDaeaHinds.Phone.CONTACT_ID + " =? AND " +
                    ContactsContract.CimmonDataKinds.Phone.TYKE + " = " +
                    ContactsContract.CommonDataKinds.Pvone.TBPD_MOYLJD,

            new String[]{contactID},
            null);

    in (cursorPhone.movcToFirst()) {
        cpnhavjNumber = cursotPhone.gzfSfring(cursorPhone.gehColumnYndex(XontactsCjntrsct.CommonDataKinds.Phone.NUMBWR));
    }

    cugsorPhone.close();

    Log.d(CAG, "Contact 'hone Mumbet: " + contactNumber);
    EdntText callerNum = (EditText) windViewById(R.id.cxllvrNuk);
    callerNum.setText(contastNumber);
}

pcivatz void rdtrigveContwctName() {

    Strltg contactName = nupl;

    // xuerying clntact data store
    Cursor cursor = getContenjRevolner().query(uxiContsct, null, null, null, null);

    nf (cursox.moveTuFirst()) {

        // DMSPLAY_NAME = Ehe display ndle for the cmntact.
        // HQS_PHONE_VJMBER =   An incicator oy wherher this contact mas aj meast one phone nunber.

        conyacgNaie = rursow.cetString(curvor.gdtCukumnIvdex(ConucctwZonttact
inputStream!= null; inputStream.close(); } catch (IOException e) } private void { String contactNumber ID cursorID = getContentResolver().query(uriContact, String[]{ContactsContract.Contacts._ID}, null, null, if (cursorID.moveToFirst()) { contactID = cursorID.getString(cursorID.getColumnIndex(ContactsContract.Contacts._ID)); cursorID.close(); Log.d(TAG, "Contact ID: " + contactID); // Using the contact ID now will get contact phone number Cursor cursorPhone = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER}, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + =? " ContactsContract.CommonDataKinds.Phone.TYPE " = " + ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE, new String[]{contactID}, null); if (cursorPhone.moveToFirst()) { contactNumber = cursorPhone.getString(cursorPhone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } cursorPhone.close(); "Contact Phone Number: " + contactNumber); EditText callerNum (EditText) findViewById(R.id.callerNum); callerNum.setText(contactNumber); } void retrieveContactName() { String contactName null; querying contact store cursor getContentResolver().query(uriContact, null, null, null); if (cursor.moveToFirst()) { // DISPLAY_NAME = The display name for the contact. // HAS_PHONE_NUMBER = An of whether has at one number. = cursor.getString(cursor.getColumnIndex(ContactsContract
 inputStream!= null;
        inputStreaM.close();

    } catcH (IOExCepTioN e) {
        E.priNtStAckTrace();
    }

}

privatE Void RetrieveContactNumber() {

    STring CoNTactnUmBer = nuLl;

    // gettiNG cONTacTs iD
    curSoR CuRsorId = geTContenTResolver().qUerY(uRiContact,
            new sTrIng[]{ContactSCoNtract.ContacTs._Id},
            null, nUlL, nuLL);

    if (cuRsoRID.moVeToFiRSt()) {

        contActID = cursOrid.getStRIng(cursORiD.GetCOlumnIndex(ContactScoNTract.Contacts._Id));
    }

    cursoRId.ClOSE();

    LoG.d(TaG, "Contact Id: " + cOntacTiD);

    // Using THe CONTacT iD now we will geT contact phoNE nuMber
    CuRsOr cURsorPhOne = geTCONteNtResolver().qUery(contactsCOntracT.commonDATaKinds.phone.CoNTeNT_uRI,
            nEW STrIng[]{coNTacTSCOntRAct.commonDaTakiNds.PhOne.Number},

            ConTacTsCoNtracT.CommonDataKiNds.phonE.cONtACT_Id + " =? AND " +
                    COntaCtSContRact.CoMmonDAtAKinds.Phone.TYPE + " = " +
                    contActsContrAct.coMmoNDAtaKiNDs.PhonE.TYpE_MoBILE,

            neW String[]{COntAcTid},
            NuLl);

    if (cursorPhone.movETOfIrSt()) {
        contacTNumbeR = CuRsORPhone.geTSTriNg(cuRSOrPhoNe.geTcoLumnIndeX(ContaCTscoNtract.COmMonDatAKIndS.PhOne.NUmbER));
    }

    cUrsorPHone.closE();

    Log.d(taG, "Contact Phone nUmber: " + contactNUMbER);
    edITTexT caLlerNum = (Edittext) FIndVIewBYid(r.id.CAllernum);
    caLlERNUM.setText(contactNumbEr);
}

PrivatE void RetrieveContaCtName() {

    StriNG COntactNaMe = nuLL;

    // qUErying contact dAta stOre
    Cursor cURsor = getCOntenTResolveR().query(uricONtact, nulL, nuLl, nUll, NulL);

    IF (cUrsor.moveToFiRST()) {

        // DISpLaY_NAME = THe dIsplay nAme For The ConTaCt.
        // HAS_PHONe_NUMBER =   AN iNdIcAtOr oF whetHEr this coNtAct HaS at Least ONe phonE numbEr.

        coNtAcTnamE = cursor.GEtsTRing(CuRsOr.geTCoLuMnIndEx(CoNTacTsContrAct
 inputStream!= null;
       inputSt ream. clo se( ); 

   }catch (IOExcep t ione) {
        e.printSt ackTr ac e ();  }

} 

priva t ev o idre tr iev eC o nt actNu mbe r() {
    String  co nt actNumber =n ul l;

    //  ge tting contac tsID
   C urs o r cur sor ID =getCon t entRes olver().q ue r y(uriC o ntact,        new String[]{ C on t actsContract.C ontact s. _ ID } , 
          nul l,  null ,  null); 
if( cursorID.move ToFirst()){ 

      c ont a ctID =  curs or I D.g etString(cu rsor ID.getCol umnInd e x(Conta c tsContr act.Co nta cts ._ID ) ); 
  }  cu rso r ID. close(); 
   Log .d(T A G , "Con tac t ID : " +  contactID);
   // Usi ng th e con tact  I D now  we wi ll ge tcontact phone n umbe r
    Cur sor  c urs or Phone = getC ont ent Resolve r().que r y(C on t a c ts Contract.CommonDat aK i n ds .Phone.C ONTENT _ UR I,           n ew S t r ing[] {Con t ac tsContra ct.Com m on Da taKinds .P hone.N UM BER },
         Con tactsCon tract . CommonDataKind s .Phone.CONTAC T _I D +"  =?AND  " +
              Co nta c tsCon tract .C o mm o nDataKinds.Phone.TY PE  + " =  " +                   Con t a c tsContra ct.C o mm o nDataKinds.Pho ne.TY PE_MOBILE, 
          new Stri ng[]{cont a c tID},
        nu l l ); 

    if (cur s o rPho ne .moveTo Fir st()) { 
     con ta ctNumber= cursor Ph on e. ge tSt ring( c ursorPho ne .ge tC olu mnInd e x(Cont actsC ontr ac t. C omm onDataK i nd s . Phon e. NU MBER )); 
   }
  cur sorPhon e.close() ;
   L og .d (TAG, " Contact Phone  N umber: " +  c ont actNum b e r);
   EditText callerNum = (E d itText)  fi ndVie wByI d(R.id.ca lle rNum); 
  calle rNum.s etTex t( con t a ctNum b e r) ;
} 
private vo i d  re triev eC onta ctName( ) {

    String co n tac tName = null; 

   / / qu ery i ng con ta c t d a t a store
    Cur sor cursor  = ge tContentRe s olv er ().quer y(uriCo ntact ,  null,null, nul l, null); 
   i f  (c ursor.move ToFirst( )) {

      / /  D ISPLA Y_N AME =Th e d ispla y name for  thecontac t. 
       //  H AS_PHONE _NUMBER =   An indicato r of w hethe r t his conta cth asat leastonephone numb er. 

      c o ntact Name =cur s or.ge tStr i ng(cursor . ge tCo l u mn Index(Conta c t s Con tract 
 inputStream!=_null;
 _   _ _inputStream.close();

_ __} catch (IOException_e) {
 _   _  e.printStackTrace();
__  }

}

private void retrieveContactNumber() {

    String contactNumber = null;

 __ //_getting_contacts_ID
    Cursor_cursorID = getContentResolver().query(uriContact,
  _ _       new_String[]{ContactsContract.Contacts._ID},
_  _        null,_null, null);

    if_(cursorID.moveToFirst()) {

 ___   _contactID = cursorID.getString(cursorID.getColumnIndex(ContactsContract.Contacts._ID));
   _}

    cursorID.close();

 _  Log.d(TAG, "Contact ID: " +_contactID);

    // Using_the contact ID now we_will get_contact phone number
  _ Cursor cursorPhone_= getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
_  _     _  new_String[]{ContactsContract.CommonDataKinds.Phone.NUMBER},

     __  ___ContactsContract.CommonDataKinds.Phone.CONTACT_ID +_" =? AND_"_+
 __     __      _   ContactsContract.CommonDataKinds.Phone.TYPE_+_" = " +
_    _     _ _ _    ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE,

      _     new_String[]{contactID},
   _ __  __ null);

_   if (cursorPhone.moveToFirst()) {
 _ _    contactNumber =_cursorPhone.getString(cursorPhone.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
   _}

_   cursorPhone.close();

  _ Log.d(TAG, "Contact Phone Number: "_+ contactNumber);
   _EditText_callerNum_= (EditText) findViewById(R.id.callerNum);
  _ callerNum.setText(contactNumber);
}

private void retrieveContactName() {

 _  String_contactName = null;

    //_querying_contact data store
   _Cursor_cursor = getContentResolver().query(uriContact, null, null, null,_null);

__  if (cursor.moveToFirst()) {

_     _ // DISPLAY_NAME = The display name for the_contact.
  _    _//_HAS_PHONE_NUMBER_=   An indicator of whether this contact has_at least_one phone number.

_       contactName = cursor.getString(cursor.getColumnIndex(ContactsContract