gray laptop computer showing html codes in shallow focus photography

How to Save a phone Number in Windows Phone 7 using C# ?

The Windows Phone 7 API exposes a launcher ( SavePhoneNumberTask ) that will launch the contacts and enable to save the provided phone number to the contacts list .

To use this launcher , we might include the namespace Microsoft.Phone.Tasks.

using Microsoft.Phone.Tasks;

The SavePhoneNumberTask  chooser has a property PhoneNumber which can be used to set the phone number and the show method to launch the contacts application .
You should make sure that you set the phone number before you call the show method . 

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
     SavePhoneNumberTask savePhoneNumber = new SavePhoneNumberTask();
     savePhoneNumber.Completed += new EventHandler<TaskEventArgs>(savePhoneNumber_Completed);
     savePhoneNumber.PhoneNumber = "1987654320";
     savePhoneNumber.Show();
}

void savePhoneNumber_Completed(object sender, TaskEventArgs e)
{
     MessageBox.Show("Phone Number Saved");
}

When the savePhoneNumber.Show() method is called , the Contacts screen in WP7 is shown which enables the user to add the Phone Number to a new Contact or include the phone number to the existing user .

Once the phone number is saved , the user should press the back key to come back to the App .

Also note that similar to ComposeSMSTask , the current API doesn’t support saving the contact without opening the Contact Screen .

    2 Comments

  1. Waleed El-Badry
    October 7, 2011
    Reply

    Hi,
    Is it possible to retrieve the phone number, modify it and save it back?

  2. October 15, 2011
    Reply

    As far as i know , It is possible only via the user interaction … via Launchers …

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...