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

typedef Content as interface {
function getName() as String;
function getId() as Number;
function toIntent() as Intent;
function remove() as Void;
}

Instance Method Summary collapse

Instance Method Details

getAppCourses() as 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:

  • Iterator

    An Iterator over the persisted content objects requested

Since:

API Level 3.0.0

getAppRoutes() as 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:

  • Iterator

    An Iterator over the persisted content objects requested

Since:

API Level 3.0.0

getAppTracks() as 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:

  • Iterator

    An Iterator over the persisted content objects requested

Since:

API Level 3.0.0

getAppWaypoints() as 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:

  • Iterator

    An Iterator over the persisted content objects requested

Since:

API Level 3.0.0

getAppWorkouts() as 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:

  • Iterator

    An Iterator over the persisted content objects requested

Since:

API Level 3.0.0

getCourses() as 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 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 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 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 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 Location, options as { :name as String } or Null) as Void

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

Parameters:

  • location(Location)

    The Location object to persist

  • options(Dictionary)

    The Dictionary of options, or null to accept defaults

    • :name(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 22, 2021 10:10:32 AM