I want to get ID of Contact List Application... Currently I am using class named PhoneNumberChooserTask
like Chooser Class but I get only Number, Name, FullName. etc.. but how to get ID of that contact?
Asked
Active
Viewed 711 times
3

slugster
- 49,403
- 14
- 95
- 145

siddhpuraamitr
- 33
- 3
-
Not sure what you are referring to. Can you show your code? – user424134 Oct 13 '11 at 06:53
-
Id property actually exists but it's internal and there are no way to get it's value through the reflection (you'll get PropertyAccessException). – EgorBo Mar 21 '12 at 11:06
4 Answers
3
Yes It is possible,
Contact c = new Contact();
var Id = c.GetHashCode(); //gives the Id property value.

Isaiyavan Babu Karan
- 987
- 2
- 8
- 17
-
No - GetHashCode() is not guaranteed to return the same value between each execution (or between .NET framework versions!) - Do not use it to uniquely identify a contact as it isn't guaranteed to work! – Steve Woods Nov 26 '12 at 21:53
-
Also, the Hashcode changes if you change any properties on the contact - if you are using it as a UID, every record in your database that references a specific contact by this UID will be wrong when it changes, and the data will be orphaned. – Steve Woods Dec 03 '12 at 11:18
-
1Hi Steve, I am not sure on what basis you are saying this. but if you deobfuscate the Contact class you can see that the method GetHashCode will return ContactId. you can be right in a sense only when the windows pohne regenerates its phone database due to someting the user does with google contact/ windows live contact. – Isaiyavan Babu Karan Jan 29 '13 at 06:08
2
You have nothing to use the ID for, so it's simply not available to you as a developer. (That means it's not possible.)

Claus Jørgensen
- 25,882
- 9
- 87
- 150
-
1It is so sad and I can't understand why is the Id property internal and not the public. – EgorBo Mar 21 '12 at 11:00
-
1What do you mean I have nothing to do with the ID?! I need it to associate the person with another entity. – Andrei Rînea Jul 13 '13 at 22:15
0
According to this answer GetHashCode returns the private property ID of the contact. I have confirmed that in 3 devices (Lumia 620, Lumia 1320, Lumia 925) running Windows Phone 8.1 and it seems to work. I changed contacts details but the ID remained the same.
Uniquely identifying contacts in a Windows Phone Address Book

Community
- 1
- 1

Byron Gavras
- 970
- 10
- 16
0
For Windows Phone 8.1 RT you can just use the contact Id property. GetHashCode() is no longer needed.

timtos
- 2,225
- 2
- 27
- 39