Some applications might require extensive use of storage to save app settings. The following code helps you to directly access the variable “Country” anywhere in the project.
First of all, declare a class with the following code
public class StorageEngine
{
public string Country
{
get
{
string tempdata = string.Empty;
if(IsolatedStorageSettings.ApplicationSettings.TryGetValue("country", out tempdata))
{
}
return tempdata;
}
set
{
IsolatedStorageSettings.ApplicationSettings["country"]=value;
IsolatedStorageSettings.ApplicationSettings.Save();
}
}
}
To use the above value in code, simple initialize a new instance of the above class:
StorageEngine NEWENGINE = new StorageEngine();
Now, whenever you want to save a value, do
NEWENGINE.Country=”India”;
and whenever you want to get the stored value, simple do
String currentcountry=NEWENGINE.Country;