Search code examples
c#windowswindows-8isolatedstorage

Isolated Storage on Windows 8 (one by one)


I'm porting my game "Bustin' Jieber" on Windows Phone to Windows 8, and I have to do a isolated storage-like system to hold the settings, records and the money. I'm using this on windows phone:

IsolatedStorageSettings iosystem = IsolatedStorageSetting.ApplicationSettings;

and for example the money system;

iosystem["bjc"] = (int.Parse(iosystem["bjc"].ToString()) + (points * int.Parse(iosystem["pointduplication"].ToString())));

How can I implement this into my code? Please give me a usable code (with namespaces or so) ! Thanks! also, app is c#...


Solution

  • You can use ApplicationData.Current.LocalSettings;

    Sample Code:

    Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    
    // Create a simple setting
    
    localSettings.Values["exampleSetting"] = "Hello Windows";
    
    // Read data from a simple setting
    
    Object value = localSettings.Values["exampleSetting"];
    
    if (value == null)
    {
        // No data
    }
    else
    {
        // Access data in value
    }
    
    // Delete a simple setting
    
    localSettings.Values.Remove("exampleSetting");
    

    & here is relevant post from MSDN

    Apart from this you can try this from CodePlex [I didn't tried this before]