clearProperties() not working as expected

I don't seem to be able to clear properties in the IQ simulator:
System.println("Before: bowOffset: Application.getApp()."+ App.AppBase.getProperty("bowOffset"));
App.AppBase.clearProperties();
System.println("After: bowOffset: Application.getApp()."+ App.AppBase.getProperty("bowOffset"));

produces:
Before: bowOffset: Application.getApp().99.000000
After: bowOffset: Application.getApp().99.000000

I have "bowOffset" defined in my properties.xml as:
<property id="bowOffset" type="float">8</property>

but during testing have changes it to value 99
I am expecting the "bowOffset" property to return null after clearProperties().
  • If you set a property value in a resource definition, I don't believe that you should ever get null. The clearProperties() call will remove the values of properties that are overwritten by the application, it can't overwrite the values from the xml.

    If you want it to return null when it isn't set, don't specify the resource.

    That said, I'm not sure I understand why you're getting the value 99.0 when it looks like you should be getting the value 8. Could this be because you've got a resource override?

    Travis
  • That said, I'm not sure I understand why you're getting the value 99.0 when it looks like you should be getting the value 8. Could this be because you've got a resource override?

    Travis


    So you expect clearProperties() to revert the value back to the XML? That would make sense.
    I'm not sure what you mean by a resource override. I'm teaching myself MC by tweaking someone else's code, so what would that look like?
  • Resource overrides are covered in the Programmer's Guide. If you've already downloaded the SDK you can open ${SDKROOT}/ProgrammersGuide.html if you want to access it locally.

    Honestly, the Programmer's Guide should be required reading before you are able to install or use the SDK.

    Travis
  • For people just starting CIQ, I agree with Travis that the Programmer's Guide (and UX Guide) in the SDK give you a very good foundation. I know the first time I went through them (long, long ago!), there were things I didn't quite understand right away, and then when looking at code (the samples are what I started with - which themselves are very good to learn the code, as you also also see the "style" side from Garmin) you know where to look to see what's going on.
  • You are absolutely right, the Programmers Guide is the place to start, and maybe I should have added that I did, of course, start there before installing the SDK and have since been trawling its pages to gain an understanding of the development environment.

    And have found for previous experience when approaching new development environments (Android Java, Pebble C SDK) , that a good way to learn is to look at code examples.

    Which brings me back to the original point.

    I have checked the code and no, there are no resource overrides. The "bowOffset" property is defined once only in properties.xml in my "resources" directory of the Eclipse environment.
  • Actually, if you look at the doc for clearProperies(), there is something you might of missed (I've never used it and just noticed it in the api doc)

    "Clears the object store for the application."

    The Object Store and properties are different, and I guess I wouldn't expect it to work for settings. The OS is "local persistent storage" and stored in your app's .str (data/) file, and properties/settings are in your apps .set (settings/) file.

    It can be a bit confusing, as in general the same calls are used to read or write data to both, but they are different things.
  • The Object Store and properties are different, and I guess I wouldn't expect it to work for settings. The OS is "local persistent storage" and stored in your app's .str (data/) file, and properties/settings are in your apps .set (settings/) file.

    It can be a bit confusing, as in general the same calls are used to read or write data to both, but they are different things.


    I can find references to the OS, but no real definition. You refer to three concepts: Object Store, Properties and Settings. Could you help to clear up my confusion please?
    I checked my app's .str (data/) file, and it only acquires values with setProperty, like when I setProperty of a settings property. When I clearProperties, the file disappears, but the new value of the property remains! Where's the new value being stored?

    I don't understand.
  • There are two files.

    in apps\data there is <yourapp>.str This is the object store. Nothing in any xml file about this.
    in apps\settings is <yourapp>.set These are your settings, as defined using <properties> in the XML

    They are both accessed by getProperty() and setProperty(). Yes, it can be a bit confusing.

    You are using the .set (not the object store) based on the xml you posted.
  • So, if I have it right,
    • the only way to reset a "settings" property back to the original value in the XML is with setProperty({original value}).
    • clearProperties() only applies to properties other than settings.
    • settings aren't really part of the Object Store



    I'm glad you cleared that up.
    Thanks.