Access roaming data in the cloud by using SkyDrive
Do you want to create an app that can store data in the cloud?
Do you want to access that data from any Windows 8–based device running your app?
Do you want to access cached data when a network connection isn't available?
Then read on….
Let's say you want to create a roaming-data app that enables users to update and manipulate text items on a variety of Windows 8–based devices, like a laptop and a Surface with Windows RT. You want to allow the user to sign in to a SkyDrive account automatically by using Microsoft account credentials. You also want users to be able to perform quick searches by using friendly file names, and to display cached data when the network connection is unavailable. SkyDrive helps you create apps that can do these things.
Here are some details to get you started.
Choosing SkyDrive
SkyDrive is just one choice among various technologies for handling roaming data. Some other options include Windows Azure SQL Database, which supports many newer platforms through Windows Azure Mobile Services, and also enables features like push notifications. SkyDrive is a free alternative to Windows Azure that works nicely as a lightweight data solution. For Windows Store apps, you can also use the roaming app data feature provided for Windows 8. If your app accesses file-based user data, SkyDrive is a good choice. Also, SkyDrive offers larger storage capacity than the roaming app data feature. For more info on the distinction between app data and user data, see App data.
Prerequisites
Tools
Before you can create a Windows Store app for your Windows 8–based devices, you need a few tools, like Visual Studio. After you've installed the required tools, you need to obtain a developer license.
To enable interaction with SkyDrive in your app and enable signing in with Microsoft account credentials, you need to use Live Connect. To use Live Connect, install the Live SDK.
Accounts
You need two accounts before you can develop your own app by using Live Connect:
· A Microsoft account, which also comes with a free SkyDrive account.
· A Windows Store developer account
Building a Windows Store app by using SkyDrive
Step 1: Create your app
Use Visual Studio to create a new project. In the SkyDrive Roaming Data sample app we use to demonstrate code, we started with the Blank App project template for a Windows Store app built for Windows using JavaScript.
Next, add a reference in your app to the Live SDK.
Step 2: Register your app
After you have created your new project, use this tutorial to register your app to use Live Connect.
Important Unlike most features in Windows 8, Live Connect features require that you configure your Windows Store apps on the Windows Store Dashboard before your app can use the features in Visual Studio.
Step 3: Update the app manifest
You can use the Manifest Designer to set capabilities and add declarations for your app. For more info, see Using the Manifest Designer.
To set capabilities in the manifest, select the Capabilities tab in the Manifest Designer. To create the sample app we use to demonstrate roaming data, you need to add these capabilities to the app manifest:
· Internet (Client)
· Documents Library
The Documents Library capability enables you to cache data locally.
The SkyDrive Roaming Data sample app stores a data file on SkyDrive. To allow the use of a data file (a file that uses the .dat file extension), you need to register this declaration:
· File Type Associations
Use the Declarations tab of the Manifest Designer to set declarations. You also need to set some properties for the File Type Associations. Set the Name property to data, and set the File type property to .dat.
Step 4: Authenticate a user
Windows Store apps that use Live Connect to access a user's private data are required to follow a set of consent and privacy guidelines. Use this tutorial to learn how to authenticate a user with single sign-in by using Microsoft account credentials. The tutorial implements guidelines for the sign-in experience that are described here.
If you want to implement the guidelines for single sign-in later, you can skip this step and come back to it later.
Step 6: Develop your app
To see how we implemented features in our SkyDrive Roaming Data sample app, including searching SkyDrive for user-specified friendly file names and caching local data, see this document:
· Interacting with SkyDrive
You can find help for developing your app in the SkyDrive documentation.