EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

ApplicationDataContainer class

Applies to Windows and Windows Phone

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

Syntax


var applicationDataContainer = applicationData.localSettings;
var applicationDataContainer = applicationData.roamingSettings;

Attributes

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

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-onlyGets the child application settings containers of this application settings container.

Locality

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

Name

Read-onlyGets the name of the current settings container.

Values

Read-onlyGets 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.


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

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

DLL

Windows.Storage.ApplicationData.dll

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

 

 

Mostrar:
© 2014 Microsoft