ApplicationData class

Applies to Windows and Windows Phone

Provides access to the application data store. Application data consists of files and settings that are either local, roaming, or temporary.

Syntax

Public NotInheritable Class ApplicationData

Attributes

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

Members

The ApplicationData class has these types of members:

Events

The ApplicationData class has these events.

EventDescription
DataChanged Occurs when roaming application data is synchronized.

 

Methods

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

MethodDescription
ClearAsync() Removes all application data from the local, roaming, and temporary app data stores.
ClearAsync(ApplicationDataLocality) Removes all application data from the specified app data store.
SetVersionAsync Sets the version number of the application data in the app data store.
SignalDataChanged Sends a DataChanged | datachanged event to all registered event handlers.

 

Properties

The ApplicationData class has these properties.

PropertyAccess typeDescription

Current

Read-onlyProvides access to the app data store associated with the app's app package.

LocalFolder

Read-onlyGets the root folder in the local app data store.

LocalSettings

Read-onlyGets the application settings container in the local app data store.

RoamingFolder

Read-onlyGets the root folder in the roaming app data store.

RoamingSettings

Read-onlyGets the application settings container in the roaming app data store.

RoamingStorageQuota

Read-onlyGets the maximum size of the data that can be synchronized to the cloud from the roaming app data store.

TemporaryFolder

Read-onlyGets the root folder in the temporary app data store.

Version

Read-onlyGets the version number of the application data in the app data store.

 

Remarks

ApplicationData provides local, temporary, and roaming storage for app data on a per-user basis. Use this class to preserve app-specific data between sessions and across multiple devices.

ApplicationData does not provide access to files in an app package. To do this, use Windows.ApplicationModel.Package.InstalledLocation.

ApplicationData.Current gives you the app's ApplicationData instance. Use this instance to get to the app data storage through one of these properties:

There are three main types of app data:

  • Local: stored on the device and persists across updates.
  • Roaming: copied to other devices where the user has installed the app.
  • Temporary: can be deleted by the system at any time.

There are two main types of app data storage are:

  • Settings: stores app data as key/value pairs that you can organize into nested sets. This data is saved in the Windows registry.
  • Folders: stores app data as files on the file system.

You can store your app data in app-specific, versioned formats. For more info, see Version and SetVersionAsync.

For more details on using these APIs, see Accessing app data with the Windows Runtime.

Examples

The following code example demonstrates how to get the local settings container for the app.

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

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

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++)
Quickstart: Temporary application data (JavaScript)
Quickstart: Temporary application data (C#/VB/C++)
Concepts
Application data overview
Guidelines
Guidelines for roaming application data
Guidelines for app settings
Reference
ApplicationDataCompositeValue
ApplicationDataContainer
ApplicationDataContainerSettings
Samples
Application settings sample
Application data sample

 

 

Show:
© 2014 Microsoft