Language: JavaScript and HTML | VB/C#/C++ and XAML

App state, start to finish (HTML)

Save and restore app data and the UI state of your Windows Store app so that users can pick up right where they left off.

Many users spread their work and play across multiple devices and apps, so matching the life cycle of your Windows Store app to their increasingly dynamic lifestyle is more important than ever. Users now expect your app to remember many aspects of its state—not just the main content and basic user data—as they multitask on their PC.

For example, when users come back to your app after it has been suspended, they expect it to resume on the same page it was on when they left. They expect the page to be scrolled to the same position and all of its controls to be in the same state as before, including content, text and item selection, scroll position, and input focus. They also expect your app to remember the state of previously visited pages so that they can navigate back and forward as before.

To make this experience possible, your app has to persist elements of the app state (like app settings and UI selections) through each of these stages of the app life cycle:

  • App suspension

    An app is suspended when the user switches away from it or when Windows enters a low-power state. Most apps stop running when the user switches away from them.

  • App termination

    An app is considered terminated if the user decides to close it or if it crashes.

  • App launch on a different device

    Users who are signed in to another Windows 8 device with the same Microsoft account that your app was activated with can deploy and launch your app on that device.

Many elements of app state, including most control property values, require little effort to save and restore. But preserving other kinds of app state requires more complex code or specialized techniques. For example, you can't save and roam a user password the same way you would the contents of regular text box. In general, you must balance trade-offs between simplicity, security, performance, and data integrity, depending on your specific app requirements.

Using guidelines, best practices, and code examples, we'll help you make the right choices about what elements of the app state to save and what techniques to use for the different kinds of state.

Tip  Check out the App data sample to see a comprehensive code example that shows basic types of app data and your options for storing and making it discoverable.

Step 1: Understand the Windows Store app life cycle

Before you can plan how your app will handle its data during a single app session or multiple app sessions, it's important to understand the end-to-end Windows Store app life cycle.

start icon

App lifecycle

Learn about the life cycle of a Windows Store app, from the time it's deployed through its removal.

step icon

Guidelines for app suspend and resume

Get user-experience recommendations to help you design the suspend and resume behavior of your app.

 

Step 2: Define app behavior for activation, suspend, and resume events

Define specific app behaviors for critical life-cycle events: app activation, suspension, and resume.

step icon

How to activate an app

Learn how to define the activation experience for your app.

step icon

How to suspend an app

Learn how to save important app data when the system suspends your app.

step icon

How to resume an app

Learn how to refresh displayed content when the system resumes your app.

 

Step 3: Identify app data and how you want to save it

Learn about the different types of app data and your options for storing it. Understand the differences between local, roaming, and temporary app data storage so you can create a data experience that's perfect for your app and its users.

step icon

App data

Find out about the different types of app data and the different locations you can store it.

step icon

Accessing app data with the Windows Runtime

Learn about the local, roaming, and temporary data stores available to your app.

step icon

Guidelines for roaming app data

Get user-experience recommendations to help you take best advantage of data roaming.

step icon

Quickstart: Local app data

Store and retrieve settings and files from the local app data store.

step icon

Quickstart: Roaming app data

Store and retrieve settings and files from the roaming app data store.

step icon

Quickstart: Temporary app data

Store and retrieve settings and files from the temporary app data store.

 

Step 4: Index local app data for Search

Now that you've settled on your app's behavior and how to manage app data, it's time to make sure that all of the unique data provided by your app is discoverable via local search on a Windows 8 PC.

step icon

How to index app local data

Find out how to make your local app data searchable.

step icon

How to perform rich queries on app local data

Learn how to search files in the app data store.

step icon

Navigation model

Understand how an app's navigation structure works with the app life cycle and data stores.

 

Step 5: Wrap it up

Finally, confirm that your Windows Store app meets primary Windows Store certification requirements. Make this a part of your regular debugging and testing process to catch issues before you begin the Windows Store onboarding process.

store requirements icon

Run the Windows App Certification Kit

Recommended. This helps you make sure your app fulfills Microsoft Store requirements. Run the Windows App Certification Kit whenever you add major functionality to your app.

stop icon

You’re done! You’ve added important app state and data features to your Windows Store app to help create a reliably smooth user experience.

 

Want to know more?

 

 

Show:
© 2014 Microsoft. All rights reserved.