Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of Roaming Profiles

Roaming Profiles

Wouldn’t it be cool if your settings could synchronize across machines? With roaming profiles, that is not only possible, but incredibly easy. Let’s assume your application is an eBook reader and you want to save the page the user is currently reading. The code to do this on the local machine looks like this:

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; 
localSettings.Values["currentPage"] = MyBook.CurrentPage;

Would you like to allow this setting to roam, so the user will pick up where they left off if they sign into your application on a different machine? No problem. Just change the code to look like this instead:

var roamingSettings =
     Windows.Storage.ApplicationData.Current.RoamingSettings; 
roamingSettings.Values["currentPage"] = MyBook.CurrentPage;

The second method will store the settings to the user’s roaming profile. If they don’t have a roaming profile, no problem! It will default to local storage. When they use a cloud-based login such as a Windows Live ID, the real magic starts to happen. The simple code above will result in the settings being stored in the cloud. When the user logs in to another device with the same id, the settings are downloaded from the cloud and synchronized with the local machine. That means I can stop reading Jules Vernes’ “Master of the World” on my desktop, hop in cab to the airport, pull out my Windows 8 tablet and start reading again from the same spot without having to flip through pages.

All of the synchronization is transparent to the developer and happens behind the scenes. The end user retains full control. Part of the settings they are able to configure for their machine is what settings are allowed to synchronize between machines. This provides the ultimate flexibility, and as a developer I am sure you can appreciate the simplicity.

  • + Share This
  • 🔖 Save To Your Account