Forum Xamarin Xamarin.Android

how to get email address xamarin?

StanislavPStanislavP USMember
edited June 2016 in Xamarin.Android

Hello, guys!

I try to read contacts info in my test app. Names and PhoneNumbers are read normally, but email address is not. Instead, the address number is read.
Here is my code:

`var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;

        string[] projection = { 
            ContactsContract.Contacts.InterfaceConsts.DisplayName, ContactsContract.CommonDataKinds.Phone.Number ,
        var loader = new CursorLoader (_context, uri, projection, null, null, null);
        var cursor = (Android.Database.ICursor)loader.LoadInBackground();
        var contactList = new List<Contact> ();
        if (cursor.MoveToFirst ()) {
            do {
                contactList.Add (new Contact(
                    cursor.GetString (cursor.GetColumnIndex (projection [0])),
                    cursor.GetString (cursor.GetColumnIndex (projection [1])),
                    cursor.GetString (cursor.GetColumnIndex (projection [2]))
            }  while (cursor.MoveToNext());

        return new ContactsAdapter (_context, contactList);

Maybe anyone can help me....?

Best Answer


  • soumenhaldersoumenhalder Member ✭✭✭
    edited February 25

    This is working perfect. Now can you please suggest me how to get the contact's first name, middle name, last name instead of display name?

Sign In or Register to comment.