23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

e found on the SkyDrive reference, on the Skydrive core reference (which includes a list of supported<br />

file types), and in the PhotoSky sample. A backgrounder on this and other Windows Live services can<br />

also be found on the Building Windows 8 blog post entitled Extending "Windows 8" apps to the cloud<br />

with SkyDrive.<br />

By now you probably have a number of other questions forming in your mind about how roaming<br />

actually works: “How often is data synchronized?” “How do I manage different versions?” “What else<br />

should I know?” These are good questions, and fortunately there are good answers!<br />

• Assuming there’s network connectivity, an app’s roaming state is roamed within 30 minutes on<br />

an active machine. It’s also roamed immediately when the user logs on or locks the machine.<br />

Locking the machine is always the best way to force a sync to the cloud. Note that if the cloud<br />

service is only aware of the user (that is, a Microsoft account) having only one device,<br />

synchronization with the cloud service happens only about once per day. When the service is<br />

aware that the user has multiple machines, it begins synchronizing within the 30-minute period;<br />

if the app is uninstalled on all but one machine, synchronization reverts to the longer period.<br />

• When saving roaming state, you can write values whenever you like, such as when those settings<br />

are changed. You don’t need to worry about writing settings as a group because Windows has a<br />

built-in debounce period to combine changes together and reduce overall network traffic.<br />

• If you have a group of settings that really must be roamed together, manage these as a<br />

composite setting in your roamingSettings container.<br />

• With files you create within the roamingFolder, these will not be roamed so long as you have the<br />

file open for writing (that is, as long as you have an open stream). It’s a good idea to make sure<br />

that all streams are closed when the app is suspended.<br />

• Windows allows each app to have up to 8K worth of “high priority” settings that will be roamed<br />

within one minute, thereby allowing apps on multiple devices to stay much more closely in sync.<br />

To use this, create a single or composite setting in the root of your roamingSettings with the<br />

name HighPriority—that is, roamingSettings.values["HighPriority"] (a container with this<br />

name will roam normally). So long as you keep the size of this setting below 8K, it will be roamed<br />

within a minute of being changed; if you exceed that size, it will be roamed with normal priority.<br />

See Scenario 6 of the Application data sample for a demonstration.<br />

• On a trusted PC, systemwide user settings like the Start page configuration are automatically<br />

roamed independent of app. This also includes encrypted credentials saved by apps in the<br />

credential locker; apps should never attempt to roam passwords. Apps that create secondary<br />

tiles (as we’ll see in Chapter 13) can indicate whether such tiles should be copied to a new device<br />

when the app is installed.<br />

• When there are multiple app data versions in use by the same app (with multiple app versions, of<br />

course), Windows will manage each version of the app data separately, meaning that newer app<br />

data won’t be roamed to devices with apps that use older app data versions. In light of this, it’s a<br />

332

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!