Where remove persistent data?

I have a data field that stores persistent data so that in case of suspending or shutting down the device it is available when the activity continues.
I delete the data under two conditions:

function compute(info){
...
	if (elapsedTimer == 0) {
		Storage.clearValues();
	}
...

    function onTimerReset(){
    	Storage.clearValues();
    }

But I have encountered a problem. if I finish an activity if I don't restart the device the stored variables are not emptied.
Any suggestion of where it is more correct to add the deletion?

Thanks in advance.

  • It sounds like the problem you're running into is that you are expecting onTimerReset() to be called when you complete the activity, and this isn't happening? If so, this sounds like it is a ConnectIQ bug since the documentation for that function says:

    This method is called when the time has stopped and current activity is ended.

    I'm not sure of all your requirements, but you may be able to work around the issue by putting a Storage.clearValues() call into onStop() in your AppBase object.