Propertys lost

My app has three Settings to change and they should be stored.
So I done like the ObjectStore example, using

App.setProperty(key, value);
and
value = App.getProperty(key);


The value is stored, if i use getProperty() while the App is running, I get the correkt value back.
But if I close the App and start it again, i get null for my three values.
It is the same in Simulator and on Device, but the ObjectStore example is working. I just Can't find out what I am missing. The seems to be no permission or something for saving properties.

Can somebody help me?
  • In my experience, this happens because of one of the two reasons outlined in the setProperty() documentation...

    Keys can be of type String, Number, Float, and Boolean. Values can be of type String, Number, Float, Boolean, null, and Arrays or Dictionaries containing those types. There is a limit on the size of the Properties of 8KB. If you reach this limit, the properties will not be saved or reloaded.


    What are the key and value you're storing?
  • Thanks for your reply!
    My three settings are only booleans, so the limit of 8KB should not be exceeded ;-)
    I also tried numeric because I thought it could be a Problem of boolean, but it also didnt work.
  • Does the path to your project have a space in it?
  • Former Member
    Former Member over 9 years ago
    Are you sure you are not calling setProperty (or clearProperties or deleteProperty) somewhere else which could reset it? Just human.
    validateProperty returns true?
  • The Path? The name of the app does not contain a blank.

    There are no clearProperties or deleteProperty used at all.
    I just added another numeric Property, for testing, so I am sure it is not set elswhere in the App, but with the same result, the value is lost after restart :confused:.

    I will test validateProperty, didnt use it till now..
  • Validate returns "null"

    Sys.println(Lang.format("Validate Property $1$",[app.validateProperty("OptionSound",true)]));
    ==null
    Sys.println(Lang.format("Validate Property $1$",[app.validateProperty(42,1)]));
    ==null

    :confused:


    function getInitialView() {
    mainView = new SMmainView();
    Sys.println(Lang.format("get Property: $1$",[ App.getApp().getProperty(42)]));
    Sys.println(Lang.format("Set Property: $1$",[ App.getApp().setProperty(42,21)]));
    Sys.println(Lang.format("Validate Property: $1$",[ App.getApp().validateProperty(42,21)]));
    Sys.println(Lang.format("get Property: $1$",[ App.getApp().getProperty(42)]));
    return [ mainView, new BaseInputDelegate() ];
    }

    ->
    get Property: null
    Set Property: null
    Validate Property: null
    get Property: 21
  • The Path? The name of the app does not contain a blank.

    No, not the name of the app, the path to the .project file. i.e., I keep all of my projects in C:\Development\Garmin\Projects. The absolute path to the eclipse project file for my Test project is C:\Development\Garmin\Projects\Test\.project. Notice, no whitespace in the paths? Everything works fine for me. I have seen cases where users had their projects in places like C:\Documents and Settings\${User}\Desktop\Projects, and it was discovered that the spaces in the path caused problems with Eclipse or the ConnectIQ plugin.

    I can't seem to find the post, but I know it happened.

    Travis
  • ok, but that is not the case. I have C:\tools\eclipse\Workspace\Test\.project
    It doesent work on two PCs and the watch. The Object Store Example is in the same workspace and works, so I thought it was a kind of setting or something :confused:
  • Well, that sucks. If you'd like to send me your code, I'd be happy to try to reproduce it and debug it for you.

    Travis
  • Well, that sucks. If you'd like to send me your code, I'd be happy to try to reproduce it and debug it for you.
    Travis

    Thank you very much.
    But, I was able to find my bug. It wasn't a configuration error, but I used a exit() in my App.OnStop() function. I did that because of a strange "hang on stop" bug. The Workaround worked well, but had this sideeffect to not save the properties.
    I removed the exit() call and found an other error that caused the App to not stop properly.
    Now everything is working well :-)