Reported as bug #2983

http://code.google.com/p/android/issues/detail?id=2983


On Jun 13, 1:34 pm, Doug <[email protected]> wrote:
> Wow! Turns out the query code in ContactsProvider does pretty much
> what I thought... it uses the Sqlite 'glob' operator, which is like
> 'like' (but uses '*' as wild-card... which is strange, since phone
> numbers could conceivably have *'s and #'s in them).
> Both GLOB and LIKE in Sqlite don't let you start a string with the
> wildcard character - hence the reversal.
>
> * When a phone number is inserted the "NUMBER_KEY" column is inserted
> as a stripped and reversed copy of 'NUMBER'.
> * The query the phone does when you get an incoming call appears based
> on the "Contacts.Phones.CONTACT_FILTER_URI" - so...
> Cursor c = resolver.query(Uri.withAppendedPath
> (Contacts.Phones.CONTENT_FILTER_URL, number));
>
> should get you the same results as the phone gets on an incoming call.
>
> As for "so_is"'s comment - yeah, they seem to set the key when a
> record is created, but never seem to bother updating it.
> Should be easy enough to verify - create a contact with phone number
> "X", then edit the phone number to be "Y" - call the number (or have
> them call you) and see if the contact info appears... if it does - we
> have more digging to do.
>
> On Jun 13, 12:30 pm, Doug <[email protected]> wrote:
>
> > I did some experimentation yesterday on just this topic.
>
> > For a start, it was easy enough to just throw a non-specific query at
> > the People provider and get back the values for the columns I was
> > interested in.
> > I don't know why, but I found that the "NUMBER_KEY" column has the
> > original phone number, unformatted, but ***reversed***.
> > So, 800-123-4567 (which is what you'd find in NUMBER column) would be
> > present as "7654321008" in the NUMBER_KEY column.
>
> > My only guess is that someone did some research and found that using
> > "NUMBER_KEY like '7654321008%' "performed better than "NUMBER_KEY like
> > '%8001234567' "  (in cases where the phone number stored for the
> > contact has extra digits - i.e. "+1").  (I really don't know - just
> > trying to rationalize why it could be backwards)
>
> > On Jun 12, 3:28 am, so_is <[email protected]> wrote:
>
> > > I would like to add something.
>
> > > I have recognized that the column "NUMBER_KEY" doesn't get updated at
> > > all. So I'd like to ask if there is another way to get normalized
> > > phone numbers?
>
> > > On 12 Jun., 11:25, code_android_festival_way
>
> > > <[email protected]> wrote:
> > > > Hello.
>
> > > > I am using a PhoneStateListener to determine the incomingNumber for a
> > > > phone call. What is the right way to get the corresponding contact
> > > > name?
>
> > > > I have tried:
>
> > > >http://paste.pocoo.org/show/LuRcRJZImQvEgSpE1uzV/
>
> > > > ( I have also used People.NUMBER_KEY)
>
> > > > But I'm always getting a cursor with the count of zero. (the number is
> > > > in the phonebook)
>
> > > > Why doesn't that work?
>
> > > > I'm looking forward reading your responses. Thank you very much.
>
> > > > Regards
--~--~---------~--~----~------------~-------~--~----~
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