Reputation: 21
is it possible in a WP7 app to save some objects which i create and then load it when the app is started again?
Upvotes: 2
Views: 800
Reputation: 3831
try after the example code above to add this. IsolatedStorageSettings.ApplicationSettings.save
Upvotes: 0
Reputation: 1353
Here's an example storing a string, but you should be able to store any type of object this way. Add IsolatedStorage to your references:
using System.IO.IsolatedStorage;
In your class:
private string myString;
In the Loaded event for your page:
try
{
myString = (string)IsolatedStorageSettings.ApplicationSettings["myString"];
}
catch
{
IsolatedStorageSettings.ApplicationSettings.Add("myString", "this value is a string");
}
and later, when you want to save:
IsolatedStorageSettings.ApplicationSettings["myString"] = myString;
Upvotes: 1
Reputation: 69362
You'll want to look to store persistent items into IsolatedStorage. You can see an overview and an example of how to use IsolatedStorage here. There are also a range of examples on this site, showing how to save different types of objects.
Upvotes: 2