简体   繁体   中英

Using Windows.Storage in settings page in Windows Universal App

Well while creating a windows phone only app we can use IsolatedStorage property to get or write settings. Can anyone tell me what do I have to use while creating a Windows Universal app.

Like what should be used instead of these commands:

//Used for getting settings for app

localsettings = IsolatedStorageSettings.ApplicationSettings;

//Updating setting value for app

if (settings.Contains(Key))
        {
            // If the value has changed
            if (localsettings[Key] != value)
            {

                localsettings[Key] = value;
                valueChanged = true;
            }
        }

        else
        {
            localsettings.Add(Key, value);
            valueChanged = true;
        }
       return valueChanged;

//For getting the value

public T GetValueOrDefault<T>(string Key, T defaultValue)
    {
        T value;


        if (localsettings.Contains(Key))
        {
            value = (T)localsettings[Key];
        }
        // Otherwise, use the default value.
        else
        {
            value = defaultValue;
        }
        return value;

// And for saving the settings

localsettings.save();

Use Windows.Storage.ApplicationData.Current.LocalSettings instead of IsolatedStorageSettings . Also check this post for a Sample (it's for Windows 8 Apps, but should also work with W10). http://blogs.msdn.com/b/glengordon/archive/2012/09/17/managing-settings-in-windows-phone-and-windows-8-store-apps.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM