Ticket Created
over 4 years ago

WERETECH-11175

set/getProperty deprecate on sdk 4?

In current doc something has changed!!

Previous information: some function (e.g. deleteProperty) was planned to remove but not set/get.

My app run well and there are values in sim Application.AppBase.Data.

So, is documentation correct?

I have some strange app behaviour on sim:

- settings don't change

- memory peaks

- console  message "Unable to serialize app data"

- resetting settings to default

can be connected with any changes in sdk 4?

Parents
  • It'll be removed form CIQ on devices so it'll be possible to compile code with set/getProporty with sdk >4 for devices with ciq <4, correct?

    The functions would not exist for devices with ConnectIQ 5.x (System 6) support, but would exist for earlier devices. i.e., we would leave existing devices as-is (simulated and physical devices), and future devices would just not have those functions at all.

    The easiest way around this is to have a wrapper that is conditionally compiled. You can use build exclusions to select which file/function is compiled in for each device.

    // source-classicStorage/MyStorage.mc
    module MyStorage
    {
        var _theApp;
    
        function _getApp() {
            if (_theApp == null) {
                _theApp = Application.getApp();
            }
            
            return _theApp;
        }
    
        function getValue(key) {
            return _getApp().getProperty(key);
        }
        
        function setValue(key, val) {
            return _getApp().setProperty(key, val);
        }
        
        function deleteValue(key) {
            return _getApp().deleteProperty(key);
        }
        
        function clearValues() {
            return _theApp().clearProperties();
        }
    }
    
    // source-modernStorage/MyStorage.mc
    module MyStorage
    {
        function getValue(key) {
            return Storage.getValue(key);
        }
    
        function setValue(key, val) {
            return Storage.setValue(key, val);
        }
        
        function deleteValue(key) {
            return Storage.deleteValue(key);
        }
        
        function clearValues() {
            return Storage.clearValues();
        }
    }
    
    
    

    // default.jungle
    project.manifest = manifest.xml
    
    # devices that do not have Application.Storage module go here
    vivoactive_hr.sourcePath = $(vivoactive_hr.sourcePath);source-classicStorage
    
    # devices that do have Application.Storage module go here
    fenix6.sourcePath = $(fenix6.sourcePath);source-modernStorage

Comment
  • It'll be removed form CIQ on devices so it'll be possible to compile code with set/getProporty with sdk >4 for devices with ciq <4, correct?

    The functions would not exist for devices with ConnectIQ 5.x (System 6) support, but would exist for earlier devices. i.e., we would leave existing devices as-is (simulated and physical devices), and future devices would just not have those functions at all.

    The easiest way around this is to have a wrapper that is conditionally compiled. You can use build exclusions to select which file/function is compiled in for each device.

    // source-classicStorage/MyStorage.mc
    module MyStorage
    {
        var _theApp;
    
        function _getApp() {
            if (_theApp == null) {
                _theApp = Application.getApp();
            }
            
            return _theApp;
        }
    
        function getValue(key) {
            return _getApp().getProperty(key);
        }
        
        function setValue(key, val) {
            return _getApp().setProperty(key, val);
        }
        
        function deleteValue(key) {
            return _getApp().deleteProperty(key);
        }
        
        function clearValues() {
            return _theApp().clearProperties();
        }
    }
    
    // source-modernStorage/MyStorage.mc
    module MyStorage
    {
        function getValue(key) {
            return Storage.getValue(key);
        }
    
        function setValue(key, val) {
            return Storage.setValue(key, val);
        }
        
        function deleteValue(key) {
            return Storage.deleteValue(key);
        }
        
        function clearValues() {
            return Storage.clearValues();
        }
    }
    
    
    

    // default.jungle
    project.manifest = manifest.xml
    
    # devices that do not have Application.Storage module go here
    vivoactive_hr.sourcePath = $(vivoactive_hr.sourcePath);source-classicStorage
    
    # devices that do have Application.Storage module go here
    fenix6.sourcePath = $(fenix6.sourcePath);source-modernStorage

Children
  • o time I have enough memory (especially you suggest class, members and consumption memory too)  I prefer not to mix in jungle, my solution:

        function setPrp(k, v)
        {
            if(APP has :Storage)
            {
                APP.Storage.setValue(k, v);
            }else
            {
                APP.getApp().setProperty(k, v);
            }
        }
        
        function getPrp(k)
        {
            if(APP has :Storage)
            {
                return APP.Storage.getValue(k);
            }else
            {
                return APP.getApp().getProperty(k);
            }
        }