Hi,
how to get phonenumber from contactname via content uri like name from number - "content://com.android.contacts/phone_lookup/{phone_number}; projektion: display_name"?
thx
How to get number from name via content uri?
Moderator: Martin
Re: How to get number from name via content uri?
Hi,
number should work. You can also replace the variable in the content URI with an actual number and use the [...]-button of the projection field to see the name of the available columns.
Regards,
Martin
number should work. You can also replace the variable in the content URI with an actual number and use the [...]-button of the projection field to see the name of the available columns.
Regards,
Martin
-
- Posts: 7
- Joined: 02 Nov 2014 20:52
Re: How to get number from name via content uri?
Moin,
I know but i search for a way to get number as result when giving then name of the contact as var.
Danke!
I know but i search for a way to get number as result when giving then name of the contact as var.
Danke!
Re: How to get number from name via content uri?
Hi,
I don't particularly like the contacts database so I might be wrong but I think you will need to execute two queries. A first one to find the contact ID and a second query to look up the numbers.
Content URI: content://com.android.contacts/contacts
Projection: _id
Selection: display_name like 'Test Name' and has_phone_number=1
Result type: Single value
Variable: contact_id
To get the list of numbers for the contact:
Content URI: content://com.android.contacts/data/phones
Projection: data1
Selection: contact_id={contact_id}
Result type: List
Variable: numbers
To get only the primary number of the contact:
Content URI: content://com.android.contacts/data/phones
Projection: data1
Selection: contact_id={contact_id} and is_primary=1
Result type: Single value
Variable: number
Regards,
Martin
I don't particularly like the contacts database so I might be wrong but I think you will need to execute two queries. A first one to find the contact ID and a second query to look up the numbers.
Content URI: content://com.android.contacts/contacts
Projection: _id
Selection: display_name like 'Test Name' and has_phone_number=1
Result type: Single value
Variable: contact_id
To get the list of numbers for the contact:
Content URI: content://com.android.contacts/data/phones
Projection: data1
Selection: contact_id={contact_id}
Result type: List
Variable: numbers
To get only the primary number of the contact:
Content URI: content://com.android.contacts/data/phones
Projection: data1
Selection: contact_id={contact_id} and is_primary=1
Result type: Single value
Variable: number
Regards,
Martin
-
- Posts: 7
- Joined: 02 Nov 2014 20:52
Re: How to get number from name via content uri?
<spock>fazinierend<\spock>
Es funktioniert, vielen Dank!
Andreas
Es funktioniert, vielen Dank!
Andreas