Application.storage getvalue/setvalue vs Simulator. Tips & tricks for testing/debugging initial state...

I'm testing my app that uses Application.storage getvalue/setvalue and I'm a bit puzzled about how the sim behaves.

When I first launch VS code and run the app/sim, there are nothing in storage as confirmed with CMD+S (I'm on mac). This is fine as this emulates the app first launch and my code obviously needs to handle this and drop in defaults or whatever..

I have issues with this and is debugging it, so I need a "clean launch". But even if I close sim & VSC, values remain on the next launch. I need to restart the computer completely to make the values go away.

File->Edit Persistent Storage->Edit Application.Storage data (cmd+s) gives no way to kill the data. Not even a single entry or elements in a array. 

I guess I could just drop a clearValues() in the onStop while testing. But is that how we are supposed to debug this??

Update: While writing this, I wrongly assumed I had to do deleteValue() on each one of them, but just now noticed the clearValues()... Would still like to hear how you guys do this though? 

  • What you can do is just delete the files used for Storage in the sim's temp directory

    for me on windows, it's under C:\Users\James\AppData\Local\Temp\com.garmin.connectiq\GARMIN>

    using cd %tmp% then

    cd com.garmin.connectiq\garmin

    gets you there.  Under the apps folder, you'll see "data" and the files live there, with the name of your app as the first part.

    Here are the files for one of my apps called devtest

    Deleting them deletes storage for that app.  Much safer than adding to your code as that's code you may forget to remove when publishing.

    I thought that file>reset all app data

    in the sim may do it, but it doesn't. 

    file>delete all apps

    will delete the prg files, the storage, and the settings, but for all apps you're testing in the sim

  • For macOS, the simulator temp directory path is:

    $TMPDIR/com.garmin.connectiq/GARMIN

  • Thanks guys, I'll try that.

    BTW. Doing it in code does not work either. Not in onStop anyways, as it seems to also be called when the glance is dropped, so before the main view.... Took me a few rounds to figure out...