GET/SET Properties Sim Bug

I used get/set properties to save state, to recover after a device crash. It works in the simulator (close the sim without a stop and save or discard). Restart the app and the state is retrievable. Awesome! Except the device doesn't flush to "disk" until onStop() is called. So those setProperty values are not saved on a crash on the device. The sim behavior doesn't match the device behavior.

Thankfully I just found out about get/set values. Which does work in the crash scenario on the device, flushing to disk immediately.

Anyway - no biggie - but if sim/device behavior matching is important, you might consider this.
  • Did you call saveProperties()? (Which is now deprecated....)

    I don't think it was ever well-documented, but you have to call saveProperties() if you want those values to be saved immediately.
  • saveProperties (as well as loadProperies) has been a no-op for a very long time. They were depreciated way back in 1.0.x if I recall, as they weren't meant to be exposed.
    The original ObectStore gets loaded and saved as part of onStart and onStop. So no clean exit, no save The sim will force a clean exit if it can.

    Application.Storage does saves while running and would be the way to go.
  • Former Member
    Former Member
    I don't think this is a mismatch of behavior. Exiting the simulator without closing your app is not similar to a device crash. The simulator will close everything down and exit cleanly if you close it. If you kill the simulator process from the task manager, you will probably see the same behavior as a device crash.
  • Sorry for the misinformation! I guess this means CIQ1 devices have no way to reliably store data while running....
  • Former Member
    Former Member
    Originally I do think saveProperties would force the properties out to disk, but it definitely does not do anything in any current version of the SDK running on a device. You are correct that there is no way to guarantee data is persisted through a crash on 1.x devices. Logging to the debug file with println may get cached briefly in the file system layer, but would be more persistent than properties in this scenario.