Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I save settings on Windows Phone 7?

I have a settings save method I call, but I tried unload, and lost focus the application will close out and not save before ever getting to either of those methods. When should I save application settings to keep this from happening?

Should I use a timer and save every 30 seconds, or what?

like image 932
Eric Avatar asked Jun 05 '11 15:06

Eric


People also ask

Is Windows Phone still usable?

End of support means experiences with Xbox related features will have limited to no functionality. In addition, earning achievements through Windows Phone devices will be turned off starting May 16, 2022.


2 Answers

How often you save depends on your app. However, the key timings are:

  • Launching
  • Activated
  • Deactivated
  • Closing

Launching is called when the app is first launched from the main screen and Closing is called when the user presses the back key to exit your app. Naturally, you'll most likely want to save permanent data in the Closing event.

Activated is called when the user has closed your app via the Windows button and has gone back into it by pressing the back button. This doesn't get called if the user launches the app for the first time.

Likewise, the Deactivated event is called when the user presses the Windows button. Depending on your app, you'll want to save transient data at this point so that when it's restored, you can give the illusion that your app wasn't closed at all. (Otherwise, for example, all textboxes will become empty even if the user entered data before pressing the Windows button).

Those are the main events, so you can design your app around that. One thing to remember is that if your save files are going to be big, and they take longer than 10 seconds to save after the closing event is called, your app will be terminated immediately, possible corrupting the save file. Therefore, for large saves files, you should plan ahead by saving incrementally (for example, after the user has made a change that should remain permanent).

There's no one size fits all solution to this as saving timings are highly dependant on the type of app being developed. Have a read of the Execution Model MSDN Page as it goes into more detail and provides code examples.

like image 121
keyboardP Avatar answered Nov 14 '22 22:11

keyboardP


Here is a sample from MSDN on how to implement settings page for Windows Phone.

http://msdn.microsoft.com/en-us/library/ff769510(v=vs.92).aspx

like image 41
Dmitry T Avatar answered Nov 15 '22 00:11

Dmitry T