Update read-only settings

Former Member
Former Member
Hi,

I have the following issue noticed: In my datafield I have a read-only setting (version information). When I update the datafield in the Connect IQ store and download the new version to my fenix 3, then the version is not updated in the datafield settings. I need to delete the related settings file in /APPS/SETTINGS/ to get the new value. What is the best practice to deal with read-only settings or is there any parameter to tell the watch, that something is new in the settings?

Kind regards

Moritz
  • It seems that installing a new version of the app should handle this for you. That said, it does seem that you could hack your way around it with something like this...

    // expect a version string resource to be updated for new versions
    var currentVersion = Ui.loadResource(Rez.Strings.VersionNumber);

    var hasNewSettings = getProperty(currentVersion);
    if (hasNewSettings == null) {
    setProperty(currentVersion, 1);

    // must have every setting to migrate in this map
    var propertyCache = {
    "setting1" => null,
    "setting2" => null
    };

    var keys = propertyCache.keys();

    for (var i = 0; i < keys.size(); ++i) {
    var key = keys;

    // copy the value from the old settings file to our cache
    propertyCache[key] = getProperty(key);
    }

    // clear the settings file
    clearProperties();

    for (var i = 0; i < keys.size(); ++i) {
    var key = keys;

    // save the value from the cache to the new settings file
    setProperty(key, propertyCache[key]);
    }
    }
    [/CODE]
  • Former Member
    Former Member
    Thank you for the code snippet and idea. I will consider this in the future.