I am using this Xamarin.Mobile component in Xamarin.Android project. After a lot of googling and going through their samples, i found only the way to retrieve the contacts from phone to my app.
Below is my code:
AddressBook book = new AddressBook(context)
{
PreferContactAggregation = true
};
Phone ph = new Phone(){
Type = PhoneType.Mobile,
Number = "9952429044"
};
Contact ct = new Contact()
{
DisplayName = "Sai Ram",
FirstName = "Om",
MiddleName = "Sai",
LastName = "Ram",
Phones = new List<Phone>(){ph}
};
I need to save the Contact object to the phone's addressbook. I can't find any methods like book.Save(contact)
in Xamarin.Contacts
.
Xamarin.Mobile has API only for reading contacts, not for adding.
EDIT
Here is short sample of how to add new contact with mobile number to your contacts.
You can find more details about how to save other fields here. Don't forget to add WRITE_CONTACTS permission to your app.