WP7 Development Tip of the Day: Understanding persistent data and transient state

by brad 16. September 2010 06:00

Windows Phone 7 applications deal with two distinct kinds of local data:  data that belongs to the application (e.g. settings, local data storage) and data that belongs to an specific use or session of an application (e.g. page state, cached web queries).  The first kind of data is called persistent data and the second is referred to as transient state.

Persistent Data

Persistent data belongs to the application on a specific phone and is stored in isolated storage.  Every time the application is run on the phone, it accesses the same persistent data.  Persistent data can be saved when the application closes or is deactivated or it can be saved as the user navigates through the application.  In my Gas Mileage application, the gas mileage notebook entries are an example of persistent data.  A more common example is application settings.

Transient State

Transient state is data that only has value for a specific run or instance of an application.  When the application is exited by the user, this data can be safely thrown away.  However, if the application was not actively exited by the user, but was instead replaced by another application, an incoming phone call, or a launcher/chooser, then transient state must be stored safely away so it can be brought back when the application is activated again.  Transient state is stored in the PhoneApplicationService.State property.

An example of transient state might be values inputted into a form, the selected value in a list, or some cached data retrieved from a web service call.  As a developer, you can write code to save this data off when your application is deactivated and read this data to restore the app to its expected state when the application is activated.

Summary

  Scope Storage Read/Write
Persistent Data Application on single phone Isolated Storage App opened / closed, or as the app runs
Transient State Application session PhoneApplicationService State Property App deactivated / activated

 

Other Resources

More Tips

Tags:

WP7 Tip of the Day | Windows Phone

Comments

9/22/2010 10:30:20 PM #

trackback

Redtube

This site uses KeywordLuv. Enter YourName@ YourKeywords in the Name field to take advantage.

Redtube

9/29/2010 2:36:27 PM #

trackback

WP7 Development Tip of the Day: Understanding Deactivating

WP7 Development Tip of the Day: Understanding Deactivating

code badger

10/27/2010 5:56:45 AM #

trackback

Дайджест технических материалов #5 (Windows Phone 7)

Tools, Books, Guides Windows Phone 7 Developer Tools RTM (online installer) , ISO UI Design and Interaction

Oleksandr Krakovetskiy blog

4/6/2011 12:33:25 AM #

trackback

[GUIA DE ESTUDIO] 71-599 Pro: Designing and Developing Windows Phone 7 Applications

Hola a todos! El 19 de este mes podemos empezar a examinarnos del examen 71-599 beta, el cual una vez

Josue Yeray

6/21/2011 11:31:43 AM #

pingback

Pingback from chaokuaidi.com

超快递 beta版 » Windows Phone 7 资源汇总(超全)

chaokuaidi.com

5/17/2012 10:11:00 PM #

pingback

Pingback from dancecoder.com

Windows Phone 7 资源汇总 | DanceCoder

dancecoder.com

Comments are closed

About Brad

Brad Tutterow lives in Illinois and works in Missouri. He has 12 years of experience developing web sites and Windows applications using a variety of technologies and is most excited currently about Silverlight, Windows Phone 7, Halo Reach, and Visual Studio 2010.