21
votes

I was just wondering how you deal with IsolatedStorageSettings in Windows Phone 8.1 SDK. For Example:

IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent")

How does this work in 8.1? As in, how do I write this statement without getting context errors. I feel like it's been deprecated or something because it does not resolve to a known namespace or anything.

I am working with maps for my current project and porting it to 8.1 gives me some syntax trouble. I have tried looking it up but I think it's too soon for documentation I guess because MSDN doesn't even say anything about it, unless I missed it by accident. Any help is appreciated.

1
What else are you expecting them to tell you beside that this method returns a boolean ? msdn.microsoft.com/en-us/library/cc614991(v=vs.95).aspxaybe
I am wondering how to use that same statement in the new SDK without getting errors. The current one doesn't resolve to a namespace, so it must be deprecated or something, like they changed it.Failsafe
I've just tried and it works fine. It's in the System.IO.IsolatedStorage namespace.aybe
Well the only thing I can use from System.IO is System.IO.Compression.Failsafe
Not sure what's wrong on your side, here it works out of the box. That method is located in Assembly System.Windows C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\System.Windows.dllaybe

1 Answers

45
votes

Use the classes in Windows.Storage namespace. They are new for Universal Apps. If you want the data to stay always local try Windows.Storage.ApplicationData.Current.LocalSettings. However, if you wouldn't mind them been stored in roaming settings (they would be available for your app in Windows 8.1 in case you do Universal Apps) you can use Windows.Storage.ApplicationData.Current.RoamingSettings.

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if(localSettings.Values.ContainsKey("LocationConsent"))
   DoSomething(localSettings.Values["LocationConsent"])

or

var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
if(roamingSettings.Values.ContainsKey("LocationConsent"))
   DoSomething(roamingSettings.Values["LocationConsent"])

This should resolve your issue. I wrote this from the top of my head, hopefully it will work for you.