ApplicationData ApplicationData ApplicationData ApplicationData Class

Definition

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

public : sealed class ApplicationData : IApplicationData, IApplicationData2, IApplicationData3
public sealed class ApplicationData : IApplicationData, IApplicationData2, IApplicationData3
Public NotInheritable Class ApplicationData Implements IApplicationData, IApplicationData2, IApplicationData3
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following code example demonstrates how to read or write to an ApplicationData folder of your choice. This example uses the LocalFolder, but the code can be slightly modified to access the LocalCacheFolder, RoamingFolder, SharedLocalFolder, or TemporaryFolder based on how your data should be stored. SharedLocalFolder has some restrictions and needs special permissions to access, for more information, see SharedLocalFolder.

// This example code can be used to read or write to an ApplicationData folder of your choice.

var applicationData = Windows.Storage.ApplicationData.current;

// Change this to var roamingFolder = applicationData.roamingFolder;
// to use the RoamingFolder instead, for example.
var localFolder = applicationData.localFolder;  

// Write data to a file
function writeTimestamp() {
   localFolder.createFileAsync("dataFile.txt", Windows.Storage.CreationCollisionOption.replaceExisting)
      .then(function (sampleFile) {
         var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
         var timestamp = formatter.format(new Date());

         return Windows.Storage.FileIO.writeTextAsync(sampleFile, timestamp);
      }).done(function () {      
      });
}

// Read data from a file
function readTimestamp() {
   localFolder.getFileAsync("dataFile.txt")
      .then(function (sampleFile) {
         return Windows.Storage.FileIO.readTextAsync(sampleFile);
      }).done(function (timestamp) {
         // Data is contained in timestamp
      }, function () {
         // Timestamp not found
      });
}
// This example code can be used to read or write to an ApplicationData folder of your choice.

// Change this to Windows.Storage.StorageFolder roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder;
// to use the RoamingFolder instead, for example.
Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;

// Write data to a file
async void WriteTimestamp()
{
   Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter = 
       new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");

   StorageFile sampleFile = await localFolder.CreateFileAsync("dataFile.txt", 
       CreationCollisionOption.ReplaceExisting);
   await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
}

// Read data from a file
async Task ReadTimestamp()
{
    try
    {
        StorageFile sampleFile = await localFolder.GetFileAsync("dataFile.txt");
        String timestamp = await FileIO.ReadTextAsync(sampleFile);
        // Data is contained in timestamp
    }
    catch (FileNotFoundException e)
    {
        // Cannot find file
    }
    catch (IOException e)
    {
        // Get information from the exception, then throw
        // the info to the parent method.
        if(e.Source != null)
        {
            Debug.WriteLine("IOException source: {0}", e.Source);
        }
        throw;
    }
}
' This example code can be used to read or write to an ApplicationData folder of your choice.

' Change this to Dim roamingFolder As Windows.Storage.StorageFolder = Windows.Storage.ApplicationData.Current.RoamingFolder
' to use the RoamingFolder instead, for example.
Dim localFolder As Windows.Storage.StorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder

' Write data to a file
Private Async Sub WriteTimestamp()
   Dim formatter As DateTimeFormatter = New DateTimeFormatter("longtime")

   Dim sampleFile As StorageFile = Await localFolder.CreateFileAsync("dataFile.txt", 
       CreationCollisionOption.ReplaceExisting)
   Await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
End Sub

' Read data from a file
Private Async Function ReadTimestamp() As Task
   Try
      Dim sampleFile As StorageFile = Await localFolder.GetFileAsync("dataFile.txt")
      Dim timestamp As string = Await FileIO.ReadTextAsync(sampleFile)
      ' Data is contained in timestamp
   Catch e1 As Exception
      ' Timestamp not found
   End Try
End Function
// This example code can be used to read or write to an ApplicationData folder of your choice.

// Change this to StorageFolder^ roamingFolder = ApplicationData::Current->RoamingFolder; to 
// use the RoamingFolder instead, for example.
StorageFolder^ localFolder = ApplicationData::Current->LocalFolder;

// Write data to a file
void MainPage::WriteTimestamp()
{
   concurrency::task<StorageFile^> fileOperation = 
       localFolder->CreateFileAsync("dataFile.txt", CreationCollisionOption::ReplaceExisting);
   fileOperation.then([this](StorageFile^ sampleFile)
   {
      auto calendar = ref new Calendar;
      auto now = calendar->ToDateTime();
      auto formatter = ref new Windows::Globalization::DateTimeFormatting::DateTimeFormatter("longtime");

      return FileIO::WriteTextAsync(sampleFile, formatter->Format(now));
   }).then([this](task<void> previousOperation) {
      try {
         previousOperation.get();
      } catch (Platform::Exception^) {
         // Timestamp not written
      }
   });
}

// Read data from a file
void MainPage::ReadTimestamp()
{
   concurrency::task<StorageFile^> getFileOperation(localFolder->GetFileAsync("dataFile.txt"));
   getFileOperation.then([this](StorageFile^ file)
   {
      return FileIO::ReadTextAsync(file);
   }).then([this](concurrency::task<String^> previousOperation) {
      String^ timestamp;

      try {
         // Data is contained in timestamp
         timestamp = previousOperation.get();
      } catch (...) {
         // Timestamp not found
      }
   });
}

For more samples and information about reading and writing to a file, see Create, write, and read a file.

Remarks

Types of application data

ApplicationData provides local, roaming, and temporary storage for app data on a per-user basis. Use this class to preserve app-specific data between sessions, users, 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 app folders or settings.

Folders are used to store app data as files on the file system. App settings are stored in key/value pairs that can be organized in to nested sets. Settings data is saved in the Windows registry.

These are the main types of app data:

  • Local: stored on the device, backed up in the cloud, and persists across updates
  • LocalCache: persistent data that exists on the current device, not backed up, and persists across updates
  • SharedLocal: persistent across all app users
  • Roaming: exists on all devices where the user has installed the app
  • Temporary: can be deleted by the system at any time

Using application folders

LocalFolder persists across updates and gets backed up to the cloud as part of the device backup. Typically, this folder should be used for user data that would be lost if it were not backed up. Some examples of data stored in LocalFolder are:

  • a user drawing for an art app
  • daily exercise history for a fitness app
  • a shopping list for a todo app By storing information in the LocalFolder, the user will not lose data after resetting the device or switching to a new device. For other types of local data that are easy to recreate and not necessary for backup and restore, use the LocalCacheFolder or TemporaryFolder.

LocalCacheFolder and TemporaryFolder are both stored locally and are not backed up to the cloud. LocalCacheFolder is under control of that app and is persistent across app sessions. LocalCacheFolder should be used for generated content needed across app sessions, such as cached files, logs, or authentication tokens. TemporaryFolder is not guaranteed to be persistent across sessions and can be deleted by the system at any time.

RoamingFolder is typically used for user preferences and customizations, links, and small data files. The contents of RoamingFolder roam across the user's devices and app instances. RoamingFolder should not be used for large amounts of data, data specific to a device, or data that relies on instant syncing.

Another folder, SharedLocalFolder, is persistent across app user accounts and should be used for large files accessed by multiple users. There is some extra set up required to access SharedLocalFolder. For more information on accessing and using this folder, see SharedLocalFolder.

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 Store and retrieve settings and other app data.

Properties

Current Current Current Current

Provides access to the app data store associated with the app's app package.

public : static ApplicationData Current { get; }
public static ApplicationData Current { get; }
Public Static ReadOnly Property Current As ApplicationData
var applicationData = Windows.Storage.ApplicationData.current;

Remarks

Application folders and settings can be accessed through the Windows.Storage.ApplicationData.current property.

See Also

LocalCacheFolder LocalCacheFolder LocalCacheFolder LocalCacheFolder

Gets the folder in the local app data store where you can save files that are not included in backup and restore.

public : StorageFolder LocalCacheFolder { get; }
public StorageFolder LocalCacheFolder { get; }
Public ReadOnly Property LocalCacheFolder As StorageFolder
var storageFolder = applicationData.localCacheFolder;
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The folder in the local app data store where you can save files that are not included in backup and restore.

LocalFolder LocalFolder LocalFolder LocalFolder

Gets the root folder in the local app data store. This folder is backed up to the cloud.

public : StorageFolder LocalFolder { get; }
public StorageFolder LocalFolder { get; }
Public ReadOnly Property LocalFolder As StorageFolder
var storageFolder = applicationData.localFolder;
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The file system folder that contains the files.

Remarks

You can access files in the local app data store using the "ms-appdata:///local/" protocol. For example:

<img src="ms-appdata:///local/myFile.png" alt="" />

To access files in the app package, use Windows.ApplicationModel.Package.Current.InstalledLocation.

To request that Windows index your app data for search, create a folder named "Indexed" under this folder and store the files that you want indexed there. Windows indexes the file content and metadata (properties) in this "Indexed" folder and all its subfolders.

Note

Content in the indexed folder will not be surfaced in a system search, but can be searched by the app.

If the device that runs this app supports app data backup, any content placed on LocalFolder will be eligible to be backed up to the cloud. Therefore if you want to persist data and keep it local to the device you should consider using LocalCacheFolder.

See Also

LocalSettings LocalSettings LocalSettings LocalSettings

Gets the application settings container in the local app data store.

public : ApplicationDataContainer LocalSettings { get; }
public ApplicationDataContainer LocalSettings { get; }
Public ReadOnly Property LocalSettings As ApplicationDataContainer
var applicationDataContainer = applicationData.localSettings;

Examples

Use the LocalSettings | localSettings property to get the settings in an ApplicationDataContainer object. Use the ApplicationDataContainer.Values | values property to access the settings in the localSettings container. This example creates and reads a setting named exampleSetting.

Call the ApplicationDataContainerSettings.Remove | remove method to delete the exampleSetting setting when you have finished with it.

Note that to access the RoamingSettings, use the same process outlined in the example, except change the occurrences of localSettings to roamingSettings

var applicationData = Windows.Storage.ApplicationData.current;

var localSettings = applicationData.localSettings;

// Create a simple setting

localSettings.values["exampleSetting"] = "Hello Windows";

// Read data from a simple setting

var value = localSettings.values["exampleSetting"];

if (!value)
{
    // No data
}
else
{
    // Access data in value
}

// Delete a simple setting

localSettings.values.remove("exampleSetting");
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

// Create a simple setting

localSettings.Values["exampleSetting"] = "Hello Windows";

// Read data from a simple setting

Object value = localSettings.Values["exampleSetting"];

if (value == null)
{
    // No data
}
else
{
    // Access data in value
}

// Delete a simple setting

localSettings.Values.Remove("exampleSetting");
Dim localSettings As Windows.Storage.ApplicationDataContainer = Windows.Storage.ApplicationData.Current.LocalSettings

' Create a simple setting

localSettings.Values("exampleSetting") = "Hello Windows";

' Read data from a simple setting

Dim value As Object = localSettings.Values("exampleSetting")

If value Is Nothing Then
   ' No data
Else
   ' Access data in value
End If

' Delete a simple setting

localSettings.Values.Remove("exampleSetting")
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;

// Create a simple setting

auto values = localSettings->Values;
values->Insert("exampleSetting", dynamic_cast<PropertyValue^>(PropertyValue::CreateString("Hello Windows")));

// Read data from a simple setting

auto values = localSettings->Values;
String^ value = safe_cast<String^>(localSettings->Values->Lookup("exampleSetting"));

if (!value)
{
    // No data
}
else
{
    // Access data in value
}

// Delete a simple setting

values->Remove("exampleSetting");

Remarks

For both LocalSettings and RoamingSettings, the name of each setting can be 255 characters in length at most. Each setting can be up to 8K bytes in size and each composite setting can be up to 64K bytes in size.

The Windows Runtime data types are supported for app settings.

See Also

RoamingFolder RoamingFolder RoamingFolder RoamingFolder

Gets the root folder in the roaming app data store.

public : StorageFolder RoamingFolder { get; }
public StorageFolder RoamingFolder { get; }
Public ReadOnly Property RoamingFolder As StorageFolder
var storageFolder = applicationData.roamingFolder;
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The file system folder that contains the files.

Remarks

The sync engine has restrictions on the file name conventions that you must follow to ensure the items in the roaming folder can roam. Be sure that your file and folder names do not contain leading whitespace. The sync engine may limit the total size of settings and files that can roam.

You can access files in the roaming app data store using the "ms-appdata:///roaming/" protocol. For example:

<img src="ms-appdata:///roaming/myFile.png" alt="" />

See Also

RoamingSettings RoamingSettings RoamingSettings RoamingSettings

Gets the application settings container in the roaming app data store.

public : ApplicationDataContainer RoamingSettings { get; }
public ApplicationDataContainer RoamingSettings { get; }
Public ReadOnly Property RoamingSettings As ApplicationDataContainer
var applicationDataContainer = applicationData.roamingSettings;

Remarks

See LocalSettings for remarks and examples on accessing RoamingSettings.

See Also

RoamingStorageQuota RoamingStorageQuota RoamingStorageQuota RoamingStorageQuota

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

public : ulong RoamingStorageQuota { get; }
public ulong RoamingStorageQuota { get; }
Public ReadOnly Property RoamingStorageQuota As ulong
var ulong = applicationData.roamingStorageQuota;
Value
ulong ulong ulong ulong

The maximum size of the data, in KB.

Remarks

If the current size of the roaming data in the roaming app data store exceeds the maximum size specified by RoamingStorageQuota, the system suspends data replication for all apps in the package to the cloud until the current size no longer exceeds the maximum size.

SharedLocalFolder SharedLocalFolder SharedLocalFolder SharedLocalFolder

Gets the root folder in the shared app data store.

public : StorageFolder SharedLocalFolder { get; }
public StorageFolder SharedLocalFolder { get; }
Public ReadOnly Property SharedLocalFolder As StorageFolder
var storageFolder = applicationData.sharedLocalFolder;
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The file system folder that contains files.

Remarks

Accessing SharedLocalFolder

SharedLocalFolder is only available if the device has the appropriate group policy. If the group policy is not enabled, the device administrator must enable it. From Local Group Policy Editor, navigate to Computer Configuration\Administrative Templates\Windows Components\App Package Deployment, then change the setting "Allow a Windows app to share application data between users" to "Enabled."

After the group policy is enabled, SharedLocalFolder can be accessed.

TemporaryFolder TemporaryFolder TemporaryFolder TemporaryFolder

Gets the root folder in the temporary app data store.

public : StorageFolder TemporaryFolder { get; }
public StorageFolder TemporaryFolder { get; }
Public ReadOnly Property TemporaryFolder As StorageFolder
var storageFolder = applicationData.temporaryFolder;
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The file system folder that contains the files.

Remarks

You can access files in the temporary app data store using the "ms-appdata:///temp/" protocol. For example:

<img src="ms-appdata:///temp/myFile.png" alt="" />

See Also

Version Version Version Version

Gets the version number of the application data in the app data store.

public : unsigned int Version { get; }
public uint Version { get; }
Public ReadOnly Property Version As uint
var uint = applicationData.version;
Value
unsigned int uint uint uint

The version number of the application data.

Methods

ClearAsync() ClearAsync() ClearAsync() ClearAsync()

Removes all application data from the local, roaming, and temporary app data stores.

Note

ClearAsync() method encounters an error if there are any open file handles. You should take care to close all open files prior to calling ClearAsync.

public : IAsyncAction ClearAsync()
public IAsyncAction ClearAsync()
Public Function ClearAsync() As IAsyncAction
Windows.Storage.ApplicationData.clearAsync().done( /* Your success and error handlers */ );
Returns

An object that is used to manage the asynchronous clear operation.

See Also

ClearAsync(ApplicationDataLocality) ClearAsync(ApplicationDataLocality) ClearAsync(ApplicationDataLocality) ClearAsync(ApplicationDataLocality)

Removes all application data from the specified app data store.

Note

ClearAsync(ApplicationDataLocality) method encounters an error if there are any open file handles. You should take care to close all open files prior to calling ClearAsync.

public : IAsyncAction ClearAsync(ApplicationDataLocality locality)
public IAsyncAction ClearAsync(ApplicationDataLocality locality)
Public Function ClearAsync(locality As ApplicationDataLocality) As IAsyncAction
Windows.Storage.ApplicationData.clearAsync(locality).done( /* Your success and error handlers */ );
Parameters
Returns

An object that is used to manage the asynchronous clear operation.

See Also

ClearPublisherCacheFolderAsync(String) ClearPublisherCacheFolderAsync(String) ClearPublisherCacheFolderAsync(String) ClearPublisherCacheFolderAsync(String)

Clears the files and subfolders from the specified subfolder of the shared storage folder for the publisher of the current app.

public : IAsyncAction ClearPublisherCacheFolderAsync(Platform::String folderName)
public IAsyncAction ClearPublisherCacheFolderAsync(String folderName)
Public Function ClearPublisherCacheFolderAsync(folderName As String) As IAsyncAction
Windows.Storage.ApplicationData.clearPublisherCacheFolderAsync(folderName).done( /* Your success and error handlers */ );
Parameters
folderName
Platform::String String String String

The subfolder of the shared storage folder for the publisher of the current app from which to clear the files and subfolders.

Returns

Represents an asynchronous action that does not return a result and does not have progress notifications. You can use this value to get the results of the operation, or to specify a method to run when the operation completes - for example, to repopulate the shared storage folder with new data.

Remarks

For more info about how to share files and folders among apps from the same publisher, see GetPublisherCacheFolder.

See Also

GetForUserAsync(User) GetForUserAsync(User) GetForUserAsync(User) GetForUserAsync(User)

Static method that returns the ApplicationData for a User.

public : static IAsyncOperation<ApplicationData> GetForUserAsync(User user)
public static IAsyncOperation<ApplicationData> GetForUserAsync(User user)
Public Static Function GetForUserAsync(user As User) As IAsyncOperation( Of ApplicationData )
Windows.Storage.ApplicationData.getForUserAsync(user).done( /* Your success and error handlers */ );
Parameters
user
User User User User

The User for which the ApplicationData is returned.

Returns

GetPublisherCacheFolder(String) GetPublisherCacheFolder(String) GetPublisherCacheFolder(String) GetPublisherCacheFolder(String)

Gets the specified subfolder of the shared storage folder for the publisher of the current app.

public : StorageFolder GetPublisherCacheFolder(Platform::String folderName)
public StorageFolder GetPublisherCacheFolder(String folderName)
Public Function GetPublisherCacheFolder(folderName As String) As StorageFolder
var storageFolder = applicationData.getPublisherCacheFolder(folderName);
Parameters
folderName
Platform::String String String String

The subfolder to get from the shared storage folder for the publisher of the current app.

Returns

Remarks

The strong security model of Windows Runtime app typically prevents apps from sharing data among themselves. It can be useful, however, for apps from the same publisher to share files and settings on a per-user basis. As an app publisher, you can register your app to share a storage folder with other apps that you publish by adding extensions to the app manifest.

Here are some examples of how you can use this shared storage folder if you publish multiple apps.

  • Share files. For example, if multiple apps use the same images or the same custom fonts, you can save these files in the shared storage folder.
  • Share the user's settings in a custom settings file. For example, if multiple apps use temperatures, you can save a copy of the user's preference for Celsius or Fahrenheit in a custom settings file in the shared storage folder. We recommend that you also store the user's settings with each app or in another master location, however, since the user can clear the contents of the shared storage folder. The shared storage folder for the app publisher is automatically provisioned when the user installs the first app from the publisher.

The shared storage folder has the following requirements and restrictions.

  • Data in the shared storage folder is not backed up or roamed. Also, the user can clear the contents of the shared storage folder.
  • You cannot use this feature to share data among apps from different publishers.
  • You cannot use this feature to share data among different users.
  • The shared storage folder does not have version management. To register an app to use the publisher's shared storage folder

Manually enter XML similar to the following example in the app manifest to register subfolders. You don't have to create these subfolders. They are automatically provisioned for you.

<Package>
    …
    <Extensions>
        …
        <Extension Category=”windows.publisherCacheFolders”>
            <PublisherCacheFolder>
                <Folder Name="Folder1">
                <Folder Name="Folder2">
            </PublisherCacheFolder>
        </Extension>
        …
    </Extensions>
    …
</Package>

To access data in the publisher's shared storage folder

Call the GetPublisherCacheFolder method to get one of the registered subfolders from the shared storage folder.

Then use the properties and methods of the StorageFolder class to read and write files and subfolders in the shared folder.

Access to the shared storage folder has the following requirements and restrictions.

  • There is no default subfolder. You have to specify a subfolder when you call the GetPublisherCacheFolder method.
  • You can only access subfolders registered in the app manifest.
  • You can't access the root of the shared storage folder. To clean up the data in the publisher's shared storage folder

Call the ClearPublisherCacheFolderAsync method to clear the files and subfolders from the specified subfolder of the shared storage folder for the publisher of the current app.

The shared storage folder is automatically cleaned up when the last app from the publisher is uninstalled.

Data saved in the shared storage folder is not linked to the app that saved it. When you uninstall the app that saved the data, the data remains in the shared storage folder until the last app from the same publisher is uninstalled.

See Also

SetVersionAsync(UInt32, ApplicationDataSetVersionHandler) SetVersionAsync(UInt32, ApplicationDataSetVersionHandler) SetVersionAsync(UInt32, ApplicationDataSetVersionHandler) SetVersionAsync(UInt32, ApplicationDataSetVersionHandler)

Sets the version number of the application data in the app data store.

public : IAsyncAction SetVersionAsync(unsigned int desiredVersion, ApplicationDataSetVersionHandler handler)
public IAsyncAction SetVersionAsync(UInt32 desiredVersion, ApplicationDataSetVersionHandler handler)
Public Function SetVersionAsync(desiredVersion As UInt32, handler As ApplicationDataSetVersionHandler) As IAsyncAction
Windows.Storage.ApplicationData.setVersionAsync(desiredVersion, handler).done( /* Your success and error handlers */ );
Parameters
desiredVersion
unsigned int UInt32 UInt32 UInt32

The new version number.

Returns

An object that is used to manage the asynchronous set version operation.

Remarks

Versioning enables you to change the application data format used in a future release of your app without causing compatibility problems with previous releases of your app. The app checks the version of the data in the data store, and if it is less than the version the app expects, the app should update the application data to the new format and update the version.

It is strongly recommended that you use sequential and incrementing version numbers, starting at 1.

SignalDataChanged() SignalDataChanged() SignalDataChanged() SignalDataChanged()

Sends a DataChanged | datachanged event to all registered event handlers.

public : void SignalDataChanged()
public void SignalDataChanged()
Public Function SignalDataChanged() As void
applicationData.signalDataChanged();

Remarks

You can use the SignalDataChanged | signalDataChanged method to fire a DataChanged | datachanged event that you can use to signal other code in your app to reload the local state.

The system automatically fires the DataChanged | datachanged event when the roaming state changes. After those changes are roamed to other devices, any instance of your app that is running on those devices will also be able to respond to the DataChanged | datachanged event by refreshing their roaming state.

See Also

Events

DataChanged DataChanged DataChanged DataChanged

Occurs when roaming application data is synchronized.

public : event TypedEventHandler DataChanged<ApplicationData, object>
public event TypedEventHandler DataChanged<ApplicationData, object>
Public Event TypedEventHandler DataChanged( Of ( Of ApplicationData ), ( Of object ))
function onDataChanged(eventArgs){/* Your code */}


applicationData.addEventListener("dataChanged", onDataChanged);
applicationData.removeEventListener("dataChanged", onDataChanged);

Examples

This example registers for the DataChanged | datachanged event.


var applicationData = Windows.Storage.ApplicationData.current;

function initialize() 
{
    applicationData.addEventListener("datachanged", datachangeHandler);
}

function dataChangeHandler(eventArgs)
{
    // TODO: Refresh your data
}
void InitHandlers()
{
   Windows.Storage.ApplicationData.Current.DataChanged += 
      new TypedEventHandler<ApplicationData, object>(DataChangeHandler);
}

void DataChangeHandler(Windows.Storage.ApplicationData appData, object o)
{
   // TODO: Refresh your data
}
Private Sub InitHandlers()
    AddHandler Windows.Storage.ApplicationData.Current.DataChanged, AddressOf DataChangeHandler
End Sub

Private Sub DataChangeHandler(ByVal appData As Windows.Storage.ApplicationData, ByVal o As Object)
    ' TODO: Refresh your data
End Sub
void MainPage::InitHandlers()
{
   Windows::Storage::ApplicationData::Current->DataChanged += 
      ref new TypedEventHandler<Windows::Storage::ApplicationData^, Object^>
      (this, &MainPage::DataChangeHandler);
}

void MainPage::DataChangeHandler(Windows::Storage::ApplicationData^ appData, Object^)
{
   // TODO: Refresh your data
}
See Also

See Also