I KNEW there have to be an easy way, but I didn't knew that it could
be that hard to find it.

After hours of searching the internet and then searching the Phone
apps sources I found it:

Uri contactUri = Uri.withAppendedPath
(Contacts.Phones.CONTENT_FILTER_URL,
                Uri.encode(number));
        Cursor cur = context.getContentResolver().query(contactUri,
projection, null, null, null);

It is THAT easy!

On 6 Jul., 18:59, Till <[email protected]> wrote:
> Yeah, I know, but to do so I would have to convert the number first.
> Trim away the country code...
> I don't know how it is with seperators, like your number.
> The incoming number would be something like "+495551234" and it is
> stored in the contact as "0555-1234". Thinking of every possibility I
> would end up with a search like "phonenumber LIKE %5%5%5%1%2%3%4"
> cause I don't know how the string is seperated in the contact and if
> it is with or without area code.
> Even though I have to check if there is an area code in the incoming
> number and trim it right away. And those area codes aren't the same
> length for all countries.
>
> On 6 Jul., 18:17, Andrew Burgess <[email protected]> wrote:
>
> > Can you use the LIKE operator, so do something for the selection args such
> > as: phonenumbers + " LIKE %555-5555%"?
>
> > On Mon, Jul 6, 2009 at 5:07 AM, Till <[email protected]> wrote:
>
> > > Hi
>
> > > What I'm trying to do, is to get the corresponding contact to a phone
> > > number. It works perfect if the number is stored in the contacts in
> > > the following format:
> > > +<countrycode><areacode><number>
> > > But not all numbers are stored this way. Most are without the
> > > countrycode or with "00" instead of "+".
>
> > > Do I have to parse the number by myself and set up a corresponding
> > > WHERE clause for the query, or is there anything I can't find in the
> > > internet to get this one done by the framework?
>
> > > Thanks
> > > Till
>
> > --
> > Andrew Burgess
--~--~---------~--~----~------------~-------~--~----~
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