Search code examples
c#uwpuwp-xamlappdata

Where are ApplicationData.RoamingSettings stored when using UWP?


I am making a UWP app and I need to store some settings for my app in roaming AppData. I am using this code to save it:

public bool[] options =
    {
        true
    };

public bool[] saveCBState =
    {
        true,
        true,
        true
    };

ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;

// Some not important code...

roamingSettings.Values[nameof(options)] = options;

if (options[0])
    roamingSettings.Values[nameof(saveCBState)] = saveCBState;
else
    roamingSettings.Values[nameof(saveCBState)] = null;

Where can I find the settings that I just saved on my computer?


Solution

  • You could directly read the values form RoamingSettings whenever you want.

    Like this:

             ApplicationDataContainer myroamingSettings = ApplicationData.Current.RoamingSettings;
    
            // load a setting that is local to the device
            var optionValue = myroamingSettings.Values[nameof(options)];
            var CBStateValue = myroamingSettings.Values[nameof(saveCBState)];
    

    Also, please check the document that @Raymond Chen posted- https://learn.microsoft.com/en-us/windows/uwp/get-started/settings-learning-track#what-do-you-need-to-know, ApplicationData.Current.RoamingSettings gets the application settings container from the roaming app data store. Settings stored here no longer roam (as of Windows 11), but the settings store is still available.