Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 8.1 - Isolated Storage

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.

like image 862
Failsafe Avatar asked Apr 16 '14 22:04

Failsafe


1 Answers

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.

like image 78
LPains Avatar answered Nov 14 '22 21:11

LPains