ApplicationDataCreateDisposition enumeration
Specifies creation options for application data containers.
Syntax
public enum class ApplicationDataCreateDisposition
Attributes
- VersionAttribute(NTDDI_WIN8)
Members
The ApplicationDataCreateDisposition enumeration has these members.
| Member | Value | Description |
|---|---|---|
| Always | always | 0 |
Always activate the container. If the resource represented by the object does not exist, create it. |
| Existing | existing | 1 |
Activate the container only if the resource it represents already exists. |
Remarks
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
Call the ApplicationDataContainer.CreateContainer | createContainer method to create a settings 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.
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings; // Create a setting in a container ApplicationDataContainer^ container = localSettings->CreateContainer("exampleContainer", ApplicationDataCreateDisposition::Always); if (localSettings->Containers->HasKey("exampleContainer")) { auto values = localSettings->Containers->Lookup("exampleContainer")->Values; values->Insert("exampleSetting", "Hello Windows"); } // Read data from a setting in a container bool hasContainer = localSettings->Containers->HasKey("exampleContainer"); bool hasSetting = false; if (hasContainer) { auto values = localSettings->Containers->Lookup("exampleContainer")->Values; hasSetting = values->HasKey("exampleSetting"); } // Delete a container localSettings->DeleteContainer("exampleContainer");
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
- Tasks
- Quickstart: Local application data (JavaScript)
- Quickstart: Local application data (C#/VB/C++)
- Quickstart: Roaming application data (JavaScript)
- Quickstart: Roaming application data (C#/VB/C++)
- Concepts
- Application data overview
- Reference
- ApplicationDataContainer.CreateContainer
Build date: 5/16/2013
