Share via


ApplicationDataContainer Class

Definition

Represents a container for app settings. The methods and properties of this class support creating, deleting, enumerating, and traversing the container hierarchy.

[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ApplicationDataContainer
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ApplicationDataContainer : System.IDisposable
Inheritance
Object ApplicationDataContainer
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

Call the ApplicationDataContainer.CreateContainer method to create a settings container, or to return an existing container. This example creates a settings container named exampleContainer and adds a setting named exampleSetting. The Always value from the ApplicationDataCreateDisposition enumeration indicates that the container should be created if it does not already exist.

Use the ApplicationDataContainer.Values property to access the exampleSetting setting in the exampleContainer container.

Call the ApplicationDataContainer.DeleteContainer method to delete the exampleContainer settings container when you have finished with it.

Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

// Create a setting in a container

Windows.Storage.ApplicationDataContainer container = 
   localSettings.CreateContainer("exampleContainer", Windows.Storage.ApplicationDataCreateDisposition.Always);

if (localSettings.Containers.ContainsKey("exampleContainer"))
{
   localSettings.Containers["exampleContainer"].Values["exampleSetting"] = "Hello, Windows!";
}

// Read data from a setting in a container

bool hasContainer = localSettings.Containers.ContainsKey("exampleContainer");
bool hasSetting = false;

if (hasContainer)
{
   hasSetting = localSettings.Containers["exampleContainer"].Values.ContainsKey("exampleSetting");
}

// Delete a container

localSettings.DeleteContainer("exampleContainer");

Remarks

Note

There is no settings container for the temporary app data store.

The Values property gets an ApplicationDataContainerSettings object that provides access to the settings stored in the container.

Properties

Containers

Gets the child application settings containers of this application settings container.

Locality

Gets the type (local or roaming) of the app data store that is associated with the current settings container.

Name

Gets the name of the current settings container.

Values

Gets an object that represents the settings in this settings container.

Methods

Close()

Note

This member is not implemented in C#.

CreateContainer(String, ApplicationDataCreateDisposition)

Creates or opens the specified settings container in the current settings container.

DeleteContainer(String)

Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also