I've got a Windows Store App that need to save data on Suspending
. Everything works fine except when
In this case the Suspending
-event is not fired (so no data is saved) and at the same time the app is restarted without any previous state (previous state in OnLaunched
is NotRunning
) so the app must reinitialize everything.
How can state be preserved between these "user sessions"?
You can't detect when your application is closed. There is only OnLuanched, OnSuspending and OnResumed events. When they close the application out, the intent is that the user wants the application to start fresh the next time it is launched.
You can start serializing all data changes to file, but this is overkill. The user closed the app, initialize it as normal.