This sample shows you how to store and retrieve data that is specific to each user and Windows Runtime app by using the Windows Runtime application data APIs (Windows.Storage.ApplicationData and so on).

Note  This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on both Windows 8.1 and Windows Phone 8.1. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see Build apps that target Windows and Windows Phone 8.1 by using Visual Studio.

Application data includes session state, user preferences, and other settings. It is created, read, updated, and deleted when the app is running. The operating system manages these data stores for your app:

If you use roaming data in your app, your users can easily keep your app's application data in sync across multiple devices. The operating system replicates roaming data to the cloud when it is updated, and synchronizes the data to any other devices on which the app is installed, reducing the amount of setup work that the user needs to do to install your app on multiple devices.

If you use local data in your app, your users can back up application data in the cloud. This application data can then be restored back on any other device while setting up the device with the same account.

The sample covers these key tasks:

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013 Update 2, go to Microsoft Visual Studio 2013.

Related topics

Windows 8 app samples
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++)
Guidelines
Guidelines for roaming application data
Concepts
Application data
Reference
Windows.Storage.ApplicationData
Windows.Storage.ApplicationDataCompositeValue
Windows.Storage.ApplicationDataContainer
Windows.Storage.ApplicationDataContainerSettings
WinJS.Application

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2
Phone
Windows Phone 8.1

Build the sample

  1. Start Visual Studio 2013 Update 2 and select File > Open > Project/Solution.
  2. Go to the directory to which you unzipped the sample. Then go to the subdirectory named for the sample and double-click the Visual Studio 2013 Update 2 Solution (.sln) file.
  3. Follow the steps for the version of the sample you want:
    • To build the Windows version of the sample:

      1. Select ApplicationDataSample.Windows in Solution Explorer.
      2. Press Ctrl+Shift+B, or use Build > Build Solution, or use Build > Build ApplicationDataSample.Windows.
    • To build the Windows Phone version of the sample:

      1. Select ApplicationDataSample.WindowsPhone in Solution Explorer.
      2. Press Ctrl+Shift+B or use Build > Build Solution or use Build > Build ApplicationDataSample.WindowsPhone.

Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

Deploying the sample

Deploying and running the sample