Users today are mobile, transitioning from one device to the next throughout the day. Increasingly, these same users expect (or even demand) to take their data with them. Fortunately for us, roaming app data makes this a reality.
Today, we kick off a two-post series that explores how to use roaming app data
to give your users a truly mobile experience. In today’s blog post, we’ll explain what roaming data is, how it works, and some ways you can use it in your own app. Finally, we’ll also cover versioning and conflict resolution.
Roaming app data
Roaming app data is the way in which all Universal Windows Platform (UWP) apps keep data in sync across multiple devices. It allows you, the developer, to create apps that help users carry data such as user profiles or documents from one device to the next. Generally speaking, roaming app data breaks down into three main categories:
- App data is the data your application requires to function. This data needs to be in sync across all devices.
- User data is any data that the user initiates via the application that will synchronize across all devices. For example, if you use your Microsoft account to store Microsoft Office files in the cloud from your desktop and then open Microsoft Office on your laptop, you will be presented with a list of your recent files.
- App settings are any configuration settings for an app that will stay in sync across all devices. Think of your profile settings in Visual Studio 2015.
Before we get started digging into the API, it’s important to understand that you have two main points of entry into your roaming app data:
The built-in ApplicationData.RoamingSettings
property, which is of the type ApplicationDataContainer
, stores its data as a dictionary key/value pair with a string for the key. The key of each setting can be up to 255 characters long and the value for each setting can be no more than 8K bytes in size. Bear in mind, however, that you can only store the following data types:
- UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double
- Char16, String
- GUID, Point, Size,Rect
Although you should choose the data type that works best for you and your specific app, ApplicationDataCompositeValue
in the above list is the recommended choice. Unlike the other types, which have an 8k-byte limit, this type allows you to store up to 64K bytes. Critically, it also lets you store a subset of settings or categorize your settings...