Windows desktop applications
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ApplicationDataContainer class

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

Syntax


Public NotInheritable Class ApplicationDataContainer

Members

The ApplicationDataContainer class has these types of members:

Methods

The ApplicationDataContainer class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
CreateContainer Creates or opens the specified settings container in the current settings container.
DeleteContainer Deletes the specified settings container, its subcontainers, and all application settings in the hierarchy.

 

Properties

The ApplicationDataContainer class has these properties.

PropertyAccess typeDescription

Containers

Read-only

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

Locality

Read-only

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

Name

Read-only

Gets the name of the current settings container.

Values

Read-only

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

 

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.

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.


Dim localSettings As Windows.Storage.ApplicationDataContainer = Windows.Storage.ApplicationData.Current.LocalSettings

' Create a setting in a container

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

If localSettings.Containers.ContainsKey("exampleContainer") Then
    localSettings.Containers("exampleContainer").Values("exampleSetting") = "Hello Windows"
End If

' Read data from a setting in a container

Dim hasContainer As Boolean = localSettings.Containers.ContainsKey("exampleContainer")
Dim hasSetting As Boolean = False

If hasContainer Then
    hasSetting = localSettings.Containers("exampleContainer").Values.ContainsKey("exampleSetting")
End If

' Delete a container

localSettings.DeleteContainer("exampleContainer")

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

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 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

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

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06020000)]

See also

Object
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
ApplicationData
ApplicationDataCompositeValue
ApplicationDataContainerSettings
Samples
Application data sample

 

 

Show:
© 2016 Microsoft