Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique Contact ID

Does android assign unique constant IDs to every contact?
If not, is there a way to assign such information to them? Could I sync this ID to google contacts?

Thanks.

like image 863
user1651653 Avatar asked Sep 06 '12 17:09

user1651653


People also ask

What is your unique ID number?

Your unique identifier is usually the last four digits of your SSN or your employee ID. This can change by group though, so check the instructions provided by your employer.

What is the use of unique ID?

Unique identifiers in a database are used to distinguish fields from each other. A unique identifier is used when information is called from the database and needs to be distinguished from other information in the database.

How long is a unique ID?

00. What is a UUID. Universally Unique Identifiers, or UUIDS, are 128 bit numbers, composed of 16 octets and represented as 32 base-16 characters, that can be used to identify information across a computer system.


3 Answers

You can retrieve unique ids for only synced Google contacts. In other cases you may get different ids as in Android raw_id of every contact is changed whenever user resets or re-imports contacts to phone-book.

If you want consistency in contact-ids irrespective of device, platform then either use only synced Google contacts or write your own work around code to generate unique ids for e.g. get hash of contact's number,name etc which rarely changes

like image 89
Pawan Maheshwari Avatar answered Oct 11 '22 19:10

Pawan Maheshwari


There are two type of contact ids in the android contacts.

one is CONTACT_ID ans other is RAW_CONTACT_ID

Refer this tutorial. ANDROID CONTACTS

hope this will help you.

like image 42
Rushabh Patel Avatar answered Oct 11 '22 18:10

Rushabh Patel


ContactsContract.RawContacts    SOURCE_ID

A string value that uniquely identifies this raw contact to the account in which it was created

When a sync adapter creates a new raw contact, this column should be set to the server's unique ID for the raw contact. When an Android application creates a new raw contact, the application should leave this column empty. This signals the sync adapter that it should create a new raw contact on the server, and get a value for the SOURCE_ID. In particular, the source id must be unique for each account type and should be stable across syncs:

Unique: Each raw contact for an account must have its own source id. If you don't enforce this, you'll cause problems in the contacts application. Notice that two raw contacts for the same account type may have the same source id. For example, the raw contact "Thomas Higginson" for the account [email protected] is allowed to have the same source id as the raw contact "Thomas Higginson" for the account [email protected]. Stable: Source ids are a permanent part of the online service's data for the raw contact. For example, if the user clears Contacts Storage from the Apps settings and re-syncs, the restored raw contacts should have the same source ids as before. If you don't enforce this, shortcuts will stop working.

Here is the official doc: Contacts Provider

like image 36
Johann Avatar answered Oct 11 '22 19:10

Johann