Depreciation of loadProperties() and saveProperties()

Former Member
Former Member
Hi, I am reading that both loadProperties() and saveProperties() will be depreciated in ConnectIQ 3.0.0

Is there a replacement? IS it getProperty()?

Usually when something that may be necessary is being removed, it usually has a replacement should be notified.

I may not necessarily need it but was reviewing existing code that I was going to build on and I see it being used. I do not want to code with it if it is going away.

Thanks,

John
  • Former Member
    Former Member over 9 years ago
    update

    after reading a little more and analyzing I am guessing that loadProperties() is just no longer needed as a prerequisite to getProperties().

    Please confirm my assumptions.

    Thanks,

    John
  • You are correct. loadProperties() and saveProperties() don't really do anything today (actually since about 1.1.2 of the SDK IIRC), and the timeframe is just so you have time to delete them from your code.

    getProperty() and setProperty() will be left as they are.
  • Former Member
    Former Member over 9 years ago
    thanks

    Thanks for the quick reply!

    John
  • What I recall is that loadProperties() and saveProperties() have always been done "behind the scenes" in CIQ, and therefore weren't needed in user code. That's why they are going away.
  • Former Member
    Former Member over 9 years ago
    ok

    thanks. I am new to Monkeyc so am walking through some existing code. Now if I can find where getProperty() is looking for values. I do not see it anywhere in the source.

    Base on the code below I am thinking it is just a way to set/initialize the trimode var (if not already set).


    // Make sure we have a default Triathlon mode
    var trimode = getProperty( "TriathlonMode" );
    if( trimode == null ) {
    setProperty( "TriathlonMode", 0 );
    }
  • getProperty is looking in one of two places. The Object Store (<progname>.str in the data directory), or in the setttings (<progname>.set in settings.)

    You may want to go back and look at the objectstore sample in the SDK, as uses both.
  • Former Member
    Former Member over 9 years ago
    ok

    neither seem to exist.

    I will keep looking.

    thanks for all your help.

    John
  • The settings and data dirs will both be under the apps directory, either on the watch or the temp directory for the simulator.
  • Former Member
    Former Member over 9 years ago
    ok

    Yes, they are under the Apps directory on the watch as you stated but I would think that would store properties AFTER they are set and would not be there for first time use.
  • In the case of .str (object store) files, they won't exist until you do a setProperty() AND you cleanly exit the app (that's when saveProperties() is done in the background). On a watch, that a normal thing that happens, but in the simulator, you need to cause the app to exit for the file to be created. That means using whatever is the apps "exit sequence" (sometimes the "back" button) or you do a "ctrl-k" in the simulator to end the app.

    The .set files are different, in that they can have a default value, and also be modified with "app settings" (in the simulator, look at "connect IQ>app settings editor).

    Again, look at the obectstore sample in the SDK for an example with user settings - specifically the "properties.xml" file in the resources directory of the sample. In the sample, the first screen is about the .str file, and the second page, the .set file.