ActivityRecording session.save() ?

In sailboat racing we often have two or three separate races in a day, and in my watch app I am aiming to capture the start and end of each race with a Lap record (to which I am adding some developer fields). Now that I am processing FIT files, I am trying to get to grips with the Activity recording module and am puzzled about the effect of session.save().

The docs explain save() as :"Complete the session by storing the FIT file on the file system.", but what does that actually do, when would I need to issue it, and why?

  • When you do a save(), the session if done - closed/over

    in your case, you want to do something like:

    create session

    //start race 1

    start()

    //at end of race 1

    addLap()

    stop()

    //wait for race2 and start (use existing session)

    start()

    //at end of race 2

    addLap()

    stop()

    save()

  • My question was: what's the point of the save()? The Activity file gets written when the app closes anyway.

  • Developers are expected to save or discard the session when done recording.

    If you don't save, the session will *probably* get saved automatically by the system (which is in place to prevent data loss in case of an app crash), but you shouldn't rely on it. There is nothing that indicates this is the expected behavior, so it is technically subject to change.

    Saving also has the effect of closing the fit session and releasing any memory associated with it back to the system. This is only an issue for some devices, but is something to consider.