Search code examples
raspberry-pisettingswindowsiot

How can I best share settings between Windows IoT Core apps?


I'm developing an "headless" background application that runs under Windows 10 IoT Core on a Raspberry Pi 3. However, I need a way for the user to configure the application. One way I have considered doing this is to have a separate "headed" application that the user can run to view and edit the various parameters. I could also make a web app so that no display is necessary on the Raspberry Pi.

I can't see any obvious mechanism for sharing settings between apps, or for that matter even creating persistent settings for a single app. On a desktop app I would just use the normal Properties.Settings.Default object. Is there a Universal Windows Platform equivalent of the App Settings API?


Solution

  • I can't see any obvious mechanism for sharing settings between apps

    You can check "Using cross-app communication to make apps work together".

    creating persistent settings for a single app

    For UWP, each app has system-defined root directories that you can use it for storing. The system also preserves the contents of these data stores until your app is uninstalled. You can store and retrieve setting like this:

    // Store settings
    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    localSettings.Values["setting1"] = "test1";
    localSettings.Values["setting2"] = "test2";
    
    // Retrieve settings
    var value1 = localSettings.Values["setting1"];
    var value2 = localSettings.Values["setting2"];
    

    For more information you can reference "Store and retrieve settings and other app data".