i am using contacts contract to take the phone number and name from the phone contacts... how can i take the value(the name and number) of a particular contacts into a variable.....i tried a lot but i was only able to display "DISPLAY_NAME and DATA_1".....
You can take a look at the tutorial at http://www.app-solut.com/blog/2011/03/working-with-the-contactscontract-to-query-contacts-in-android/ which covers how to query all contacts and basic information like the name or phone number for these contacts.
Related
I have a list of contact numbers and would like to get contact records of all the contacts that match the phone numbers. i have only seen queries for finding a single contact based on a single phone number search using PhoneLookup. Thanks in advance
I've got an app in the market which stores details against contacts by using a contact picker. When I've returned from the contact picker I had been using the following to obtain the contact:
cursor.getColumnIndex(ContactsContract.Contacts._ID)
I've found that using this is ok until somebody flashes a new rom or gets a new phone and then all the ID's have changed.
I've looked at the android documentation and I've seen references to using ContactsContract.Contacts.LOOKUP_KEY, but the description confuses me "An opaque value that contains hints on how to find the contact if its row id changed as a result of a sync or aggregation."
So what should I be using to store the contact ID?
Lookup Key is the correct reference for contacts.
Contacts Provider / Contacts:
The ContactsContract.Contacts table also has the column LOOKUP_KEY
that is a "permanent" link to the contact row. Because the Contacts
Provider maintains contacts automatically, it may change a contact
row's _ID value in response to an aggregation or sync. Even If this
happens, the content URI CONTENT_LOOKUP_URI combined with contact's
LOOKUP_KEY will still point to the contact row, so you can use
LOOKUP_KEY to maintain links to "favorite" contacts, and so forth.
This column has its own format that is unrelated to the format of the
_ID column.
I have an application that stores the Contact_ID of contacts. I managed to retrieve the contact_id-s from the phone's Contacts. In some cases I want to make it possible to the user to either call or send a message to the given person behind that contact_id. I don't want to store phone numbers if possible.
So I have a contact_id and I'm wondering whether it is possible to display the list of the contacts with the name behind my contact_id preselected ?
cheers
I have inserted few contacts in through the android emulator.
I wanted to fetch the names, number,emails,etc. for each contact.
I understood that for fetching contact number we need to refer to
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
instead of
ContactsContract.Contacts.CONTENT_URI
My question is how do i link both the query results so that i can aggregate a single contact and its attributes together ? It seems that only ContactsContract.Data.DISPLAY_NAME is common in both the results and the only attribute which can fetched in both the URI's without specifying in the query's projection.
Can anyone guide me ?
Thanks,
Adithya.
try these links:
How to call Android contacts list?
How to get contacts from native phonebook in android
How to obtain all details of a contact in Android
How to get the first name and last name from Android contacts?
How to import contacts from phonebook to our application
Android contacts extraction
How to get all android contacts but without those which are on SIM
Use select from ContactsContract.Data.CONTENT_URI and group results by LOOKUP_KEY. You'll receive a single cursor with phones, emails, etc., grouped by contact.
In onactivityresult we r getting cursor to the contact database to access various fields of contact database we have ContactsContract.PhoneLookup through which we can get index various db columns and then acccess them.
I've been reading for a couple hours now, trying to figure out how to maintain a reliable list of contacts in an Android application, but still cannot find one clear successful case.
My situation is this: I let users create Groups in my application, and in each Group, the user can select, from their contact list on the phone, which users they'd like to add to that group. I then need to be able to have a reliable way to compare a call from an incoming contact with my contacts database in my application, to see if they are in specific groups.
The easy parts are to add specific contacts to my database, and also to look up a contact based on their phone number. Thanks to this forum they are easy anyway! :) I'm storing the contacts in my database by Contact Name, Lookup Key, and Contact Id. The hard part for me, and this is what I cannot find a clear answer on, is how do I know that a month down the road, Contact X is going to have the same Lookup Key or Contact Id as when they were added? Couldn't they all change by then? Obviously the name can easily change, but can't the lookup_key and Contact ID also change? I've read about the lookup_key changing if contacts are manually aggregated. In other words, I am looking for the identifiable information for a contact that CANNOT change once they are entered?
I have read about using a ContentObserver to register for changes to the Contacts database, but I don't see that this helps me at all, since if I have Contact X with Lookup Key Y and Contact ID of Z, even if I get updated that the Contacts have changed, I still need to match Contact X in my application with Contact X in the Contacts database to update my info, which I still cannot do if the identifying information has been changed.
For example, I have a contact with Name, Lookup_Key, ContactID of Ted, 230ff392, 3209482. A month later, could it happen that what used to be Ted is now T-bone, 458ee247, 5502981? If this were the case, I cannot use these 3 identifiers as a means to look up the contact.
Thanks so much for the help on this!
Paul
I don't know where you read that the lookup key might change, but the documentation states that they are permanent in contrary to contact ids.
Contacts Provider / Contacts:
The ContactsContract.Contacts table also has the column LOOKUP_KEY
that is a "permanent" link to the contact row. Because the Contacts
Provider maintains contacts automatically, it may change a contact
row's _ID value in response to an aggregation or sync. Even If this
happens, the content URI CONTENT_LOOKUP_URI combined with contact's
LOOKUP_KEY will still point to the contact row, so you can use
LOOKUP_KEY to maintain links to "favorite" contacts, and so forth.
This column has its own format that is unrelated to the format of the
_ID column.