[Solved] How do i maintain session on a windows phone 8 [closed]


In WP8 there are events that are fired to tell you when the application is launched, closed, activated, or deactivated. These event handlers can be seen in the App.xaml.cs file in your Wp8 app.

// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}

// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}

// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}

// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}

Also see this diagram obtained from this pdf from Microsoft:

Windows Phone 8 Application Life cycle

So, the thing to do then is to place the appropriate code for saving and retrieving data to and from the isolated storage of the application. An example of this might be the following code that reads a stored xml file:

XElement doc;
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Open, isoStoreFile))
{
    doc = XElement.Load(isoStoreStream);
}

return doc;

The following code would save an xml file:

XElement pDoc = GetXElementYouWantToSave();
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Create, isoStoreFile))
{
    pDoc.Save(isoStoreStream);
}

solved How do i maintain session on a windows phone 8 [closed]