Windows Dev Center

ApplicationDataCreateDisposition enumeration

Specifies options for creating application data containers or returning existing containers. This enumeration is used by the ApplicationDataContainer.CreateContainer method.

Syntax


var value = Windows.Storage.ApplicationDataCreateDisposition.always;

Members

The ApplicationDataCreateDisposition enumeration has these members.

MemberValueDescription
Always | always0

Always returns the specified container. Creates the container if it does not exist.

Existing | existing1

Returns the specified container only if it already exists. Raises an exception of type System.Exception if the specified container does not exist.

Examples

Call the ApplicationDataContainer.CreateContainer | 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 | always value from the ApplicationDataCreateDisposition enumeration indicates that the container should be created if it does not already exist.

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

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


var applicationData = Windows.Storage.ApplicationData.current;

var localSettings = applicationData.localSettings;

// Create a setting in a container

var container = localSettings.createContainer("exampleContainer", 
    Windows.Storage.ApplicationDataCreateDisposition.Always);

if (localSettings.containers.hasKey("exampleContainer"))
{
    localSettings.containers.lookup("exampleContainer").values["exampleSetting"] = "Hello Windows";
}

// Read data from a setting in a container

var hasContainer = localSettings.containers.hasKey("exampleContainer");

if (hasContainer)
{
    // Access data in: 
    //   localSettings.containers.lookup("exampleContainer").values.hasKey("exampleSetting");
}

// Delete a container

localSettings.deleteContainer("exampleContainer");

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

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]

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

Attributes

[Version(0x06020000)]

See also

Tasks
Quickstart: Local application data (JavaScript)
Store and retrieve settings and other app data
Quickstart: Roaming application data (JavaScript)
Store and retrieve settings and other app data
Concepts
Store and retrieve settings and other app data
Reference
ApplicationDataContainer.CreateContainer

 

 

Show:
© 2015 Microsoft