Hi,

Please help me in solving this problem with my Android Application:

I am writing an android application to search  call log by a
particular contact number , and  contact list by a particular contact
number

To start, I added a new contact in android emulator. While writing the
contact number for the contact, a dash sign ( - ) automatically gets
inserted between the digits after some interval.
  For, e.g. If I am trying to store 9889880912 , it gets converted to
988-988-0912.
After saving my contact, I made a call to the contact so that it gets
an entry in call log.


But i found that the contact number is stored in different pattern in
contact list and call log. Suppose I have a contact with number
9889880912. Then, using my code,

If I search my contact book for number 988-988-0911  , I am able to
display the result
But if I am doing the search for contact number 9889880912 , Then no
results are found from the contact list.

Similarly, If I am doing the search in CALL LOG History for
9889880912 , I am able to display the result.

 But if I am searching for number 988-988-0912 in the call log
history, no results are displayed.



How can I search for a number 9889880912 in my contact list to get
result.  I am trying to remove this - problem.




My code for search are :

/*  Search a contact in contact list   */

 Cursor phoneResult = context.getContentResolver().query(
        
ContactsContract.CommonDataKinds.Phone.CONTENT_URI ,
                                                       null,
        
ContactsContract.CommonDataKinds.Phone.NUMBER + "=?",
                                                       new String[]
{String.valueOf(phoneNumber)},
                                                       null);


                if(phoneResult.getCount()>0)
                {
                     debugString="at least one contact with phonenumber";
                     Log.d("DEBUG",debugString);

               }

/*  search for a call log by number */


  Cursor callLogResult =
context.getContentResolver().query( callLogURI,
                                                        null,
                                                        Calls.NUMBER + "=?",
                                                        new 
String[]{String.valueOf(mobileNumber)},
                                                        null);

                           if(callLogResult.getCount()>0)
                           {
                                   debugString = "At least one call Log found";
                                  Log.d("DEBUG",debugString);
                            }


Please guide me to solve my problem.

Thanks,
NIshant Kumar

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to