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.

What We’ve Just Learned<br />

• Statefulness is important to Windows Store apps, to maintain a sense of continuity between<br />

sessions even if the app is suspended and terminated.<br />

• App data is session, local, temporary, and roaming state that is tied to the existence of an app; it<br />

is accessible only by that app.<br />

• User data is stored in locations other than app data (such as the user’s music, pictures, videos,<br />

and documents libraries, along with removable storage) and persists independent of any given<br />

app, and multiple apps might be able to open and manipulate user files.<br />

• App data is accessed through the Windows.Storage.ApplicationData API and accommodates<br />

both structured settings containers as well as file-based data. Additional APIs like IndexedDB and<br />

<strong>HTML</strong>5 localStorage are also available.<br />

• It is important to version app state, especially where roaming is concerned, as versioning is how<br />

the roaming service manages what app state gets roamed to which devices based on what<br />

version apps are looking for.<br />

• The size of roaming state is limited to a quota (provided by an API), otherwise Windows will not<br />

roam the data. Services like SkyDrive can be used to roam larger files, including user data.<br />

• The typical roaming period is 30 minutes or less. A single setting or composite named<br />

“HighPriority,” so long as it’s under 8K, will be roamed within a minute.<br />

• The StorageFolder and StorageFile classes in WinRT are the core objects for working with<br />

folders and files. All programmatic access to the file system begins, in fact, with a StorageFolder.<br />

Otherwise, the user can point to files and folders through the file picker API, which is really the<br />

first choice for file access.<br />

• Blobs are useful aids in working with files, as are the WinRT APIs in the Windows.Storage.-<br />

FileIO and PathIO classes. WinJS offers some simplified methods for reading and writing text<br />

files (especially in conjunction with app state), and the <strong>HTML</strong>5 FileReader is supported.<br />

• WinRT offers encryption services through Windows.Security.Cryptography, as well as a built-in<br />

compression mechanism in Windows.Storage.Compression.<br />

• To use the Settings pane, an app populates the top-level pane provided by Windows with<br />

specific commands. Those commands map to handlers that either open a hyperlink (in a<br />

browser) or display a settings flyout using the WinJS.UI.SettingsFlyout control. Those flyouts<br />

can contain any <strong>HTML</strong> desired, including iframe elements that load remote content.<br />

• Access to user data folders, such as media libraries, documents, and removable storage, is<br />

controlled by manifest capabilities. Such capabilities need be declared only if the app needs to<br />

access the file system in some way other than using the file picker.<br />

361

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

Saved successfully!

Ooh no, something went wrong!