×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Moratuwa, Sri Lanka
    Posts
    86

    Getting Contact Details

    Hi All,

    I want to check whether a given number is in my contact list and if it is, i need to get the name of that person.

    How can I do that using a code ?

    Regards,
    Primal

  2. #2
    Registered User
    Join Date
    Nov 2007
    Posts
    444

    Re: Getting Contact Details

    This can be done using CContactDatabase API.

    Look in SDK it has methods which will help you to do your task.

    BR.
    Kavit

  3. #3
    Registered User
    Join Date
    Feb 2007
    Location
    India
    Posts
    1,128

    Re: Getting Contact Details

    Quote Originally Posted by primal View Post
    Hi All,

    I want to check whether a given number is in my contact list and if it is, i need to get the name of that person.

    How can I do that using a code ?

    Regards,
    Primal
    Go through this link...
    http://discussion.forum.nokia.com/fo...p/t-68269.html

  4. #4
    Registered User
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    1,503

    Re: Getting Contact Details

    Hi

    Use this it works.

    Code:
    //*******************************//
    //Function for retrive contacts info
    //*******************************//
    void CSms::RetriveContactDetails(TDes& contactA,TDes& ContDetails)
    {
    	// phone number to search
        TBuf<128> callNameBuf;
        TBuf<128> label1;
        TBuf<256> ContactEntry;
        TBuf<128> ContactEntry1;
        TInt SMSNoLength;
    	SMSNoLength=contactA.Length();
    	
        CContactDatabase* iContactsDb ;
    	CContactIdArray* iMyIdArray;
    
        // Opens the default contact database           
        iContactsDb = CContactDatabase::OpenL();
        // Search for all phonebook items matching phone number
        
        iMyIdArray= iContactsDb->MatchPhoneNumberL(contactA,SMSNoLength);
        // Count of matchings found
        callNameBuf.AppendNum(iMyIdArray->Count());
        // Reading matched contacts info
      	if(iMyIdArray->Count()==0)
        {
        	//not found
        	ContDetails.Copy(_L("Number not found:"));
        	ContDetails.Append(contactA);
        }
        else
        {
        	for(TInt i = 0;i < iMyIdArray->Count();i++)
    		{
    		//	print_int(1);
    			TContactItemId id = (*iMyIdArray)[i];
    
    			// Read contact using id
    			CContactItem* contact = iContactsDb->ReadContactL(id);
    
    			// Get a reference to the contact item's field set
    			CContactItemFieldSet& fieldSet = contact->CardFields();
    			ContactEntry.Zero();
    			// Read and display all fields
    			for ( TInt j = 0 ; j < fieldSet.Count() ; j++ )
    			//for ( TInt j = 0 ; j < 3 ; j++ )			
    			{
    				const CContactItemField& field1 = fieldSet[j] ;
    				//phone numbers are stored in database using text fields
    				ContactEntry1.Copy(field1.Label());
    				if(ContactEntry1.Find(_L("name"))!=KErrNotFound || ContactEntry1.Find(_L("Name"))!=KErrNotFound)
    				{
    					ContactEntry.Append(field1.Label());
    					ContactEntry.Append(_L(":"));
    					ContactEntry.Append(field1.TextStorage()->Text());
    					ContactEntry.Append(_L("\n"));
    				}
    				
    			}
    		}
    		
        	ContDetails.Copy(ContactEntry);
        }
    
    }
    Regards,
    Amit


    ****"Putting a Smile on other's faces is the essence of true Happiness"****

  5. #5
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Moratuwa, Sri Lanka
    Posts
    86

    Re: Getting Contact Details

    Thanx aamitgupta,

    It worked... thanx a lot again

    Regards,
    Primal

Similar Threads

  1. Contact details of Nokia - Development
    By trine-entertainment in forum Audio
    Replies: 2
    Last Post: 2010-04-12, 16:17
  2. Random RingTone within Contact List for 3rd
    By cckfranky in forum Symbian
    Replies: 5
    Last Post: 2007-12-29, 18:33
  3. contact database change event details
    By rsajithali in forum Symbian
    Replies: 9
    Last Post: 2004-08-17, 00:55
  4. Contact details of Nokia - Development
    By trine-entertainment in forum General Development Questions
    Replies: 0
    Last Post: 2004-05-21, 10:54
  5. Contact details of Nokia - Development
    By trine-entertainment in forum Symbian
    Replies: 0
    Last Post: 2004-05-21, 10:52

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×