Module: Toybox.PersistedContent

Overview

The PersistedContent module allows access to stored routes, waypoints, and other stored user data.

This module provides an Iterator class that gives access to content stored on the device. Included content types are as follows:

Each of these objects can utilize System.Intents to to launch the appropriate application type for the content type (e.g. The workout might launch the workout player). This is typically used in conjunction with the Communications module to retrieve content of type .FIT and .GPX and later access it using the get methods provided within this module.

See Also:

Note:

As a general rule, Fitness and Edge devices will support .FIT format. Outdoor devices will support .GPX format.

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;
using Toybox.System;

var iterator = PersistedContent.getCourses; // Get the Iterator
var content = iterator.next();              // Get the next object in the iterator

var name = content.getName();               // Get the content name
var id = content.getId();                   // Get the content id
System.ExitTo(content.toIntent());          // Use the content for a System.Intent

Since:

API Level 2.2.0

App Types:

  • Watch App

  • Audio Content Provider

  • Widget

Supported Devices:

Requires Permission:

  • PersistedContent

Classes Under Namespace

Classes: Course, Iterator, Route, Track, Waypoint, Workout

Typedef Summary collapse

Instance Method Summary collapse

Instance Method Details

getAppCourses() as PersistedContent.Iterator

Get the subset of courses installed on the system that are owned by the application

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

// Get an iterator for all courses owned by this application
var iterator = PersistedContent.getAppCourses();

Supported Devices:

Returns:

Since:

API Level 3.0.0

getAppRoutes() as PersistedContent.Iterator

Get the subset of routes installed on the system that are owned by the application

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

// Get an iterator for all routes owned by this application
var iterator = PersistedContent.getAppRoutes();

Supported Devices:

Returns:

Since:

API Level 3.0.0

getAppTracks() as PersistedContent.Iterator

Get the subset of tracks installed on the system that are owned by the application

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

// Get an iterator for all tracks owned by this application
var iterator = PersistedContent.getAppTracks();

Supported Devices:

Returns:

Since:

API Level 3.0.0

getAppWaypoints() as PersistedContent.Iterator

Get the subset of waypoints installed on the system that are owned by the application

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

// Get an iterator for all waypoints owned by this application
var iterator = PersistedContent.getAppWaypoints();

Supported Devices:

Returns:

Since:

API Level 3.0.0

getAppWorkouts() as PersistedContent.Iterator

Get the subset of workouts installed on the system that are owned by the application

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

// Get an iterator for all workouts owned by this application
var iterator = PersistedContent.getAppWorkouts();

Supported Devices:

Returns:

Since:

API Level 3.0.0

getCourses() as PersistedContent.Iterator

Get the courses installed on the system

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

var iterator = PersistedContent.getCourses(); // Get the Iterator

Supported Devices:

Returns:

Since:

API Level 2.2.0

getRoutes() as PersistedContent.Iterator

Get the routes installed on the system

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

var iterator = PersistedContent.getRoutes(); // Get the Iterator

Supported Devices:

Returns:

Since:

API Level 2.2.0

getTracks() as PersistedContent.Iterator

Get the tracks installed on the system

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

var iterator = PersistedContent.getTracks(); // Get the Iterator

Supported Devices:

Returns:

Since:

API Level 2.2.0

getWaypoints() as PersistedContent.Iterator

Get the waypoints installed on the system

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

var iterator = PersistedContent.getWaypoints(); // Get the Iterator

Supported Devices:

Returns:

Since:

API Level 2.2.0

getWorkouts() as PersistedContent.Iterator

Get the workouts installed on the system

Example:

// Assumes content already saved on device
using Toybox.PersistedContent;

var iterator = PersistedContent.getWorkouts(); // Get the Iterator

Supported Devices:

Returns:

Since:

API Level 2.2.0

saveWaypoint(location as Position.Location, options as { :name as Lang.String } or Null) as Void

Save a Location as a Waypoint to the device's location list

Parameters:

  • location(Position.Location)

    The Location object to persist

  • options(Lang.Dictionary)

    The Dictionary of options, or null to accept defaults

    • :name(Lang.String)

      The name to assign to the waypoint. If not specified the waypoint will be named automatically.

Example:

using Toybox.PersistedContent;
using Toybox.Position;

var location = new Position.Location(
       {
       :latitude => <latitude_coordinates>,
       :longitude => <longitude_coordinates>,
       :format => :degrees
       }
);
PersistedContent.saveWaypoint(location, {:name => "Cool Waypoint Name"});

Supported Devices:

See Also:

Since:

API Level 2.2.0


Generated Apr 17, 2024 9:40:38 AM