Skip to main content
ApplicationDataContainerSettings.Add method

Adds a new item to the ApplicationDataContainerSettings.


public void Add(
  string key, 
  object value

Public Sub Add(
  key As String,  
  value As Object 



Type: System.String

The key of the new item to add.


Type: System.Object

The value of the new item to add.


The following example shows how to add an app setting by using either the Add(String, Object) or the Add(KeyValuePair)method. It also shows how to iterate over the app settings and how to access the value of an individual setting.

using Windows.Storage;
using System.Diagnostics; // For writing results to the Output window.
            // Get the app's application data.
            ApplicationData appData = ApplicationData.Current;

            // Get the data container of local settings.
            ApplicationDataContainer appLocalSettingsContainer =

            // Get the local settings and their values.
            ApplicationDataContainerSettings appLocalSettings =

            // Clear the settings for this example.

            // Add a setting by providing the key and the value separately.
            appLocalSettings.Add("key1", "value1");

            // Add another setting by providing a key-value pair.
            appLocalSettings.Add(new KeyValuePair<String, Object>("key2", "value2"));

            // Write the number of settings to the Visual Studio Output window.
            Debug.WriteLine("Number of local settings: " + appLocalSettings.Count.ToString());

            // Write the settings to the Output window.
            foreach (KeyValuePair<string, object> setting in appLocalSettings)
                //KeyValuePair<string, object> kvp = (KeyValuePair<string, object>)setting;
                Debug.WriteLine(setting.Key + ", " + setting.Value);

            // Write the value of the "key1" setting.
            Debug.WriteLine("The value of key1 is = " + appLocalSettings["key1"].ToString());

Requirements (Windows 10 device family)

Device family

API contract



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]



See also