src/main/java/de/dennisguse/opentracks/data/ContentProviderUtils.java
public static Track createTrack(Cursor cursor) {
        int idIndex = cursor.getColumnIndexOrThrow(TracksColumns._ID);
        int uuidIndex = cursor.getColumnIndexOrThrow(TracksColumns.UUID);
        int nameIndex = cursor.getColumnIndexOrThrow(TracksColumns.NAME);
        int descriptionIndex = cursor.getColumnIndexOrThrow(TracksColumns.DESCRIPTION);
        int categoryIndex = cursor.getColumnIndexOrThrow(TracksColumns.CATEGORY);
        int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
        int startTimeOffsetIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME_OFFSET);
        int stopTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STOPTIME);
        int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
        int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME);
        int movingTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MOVINGTIME);
        int maxSpeedIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXSPEED);
        int minAltitudeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MIN_ALTITUDE);
        int maxAltitudeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAX_ALTITUDE);
        int altitudeGainIndex = cursor.getColumnIndexOrThrow(TracksColumns.ALTITUDE_GAIN);
        int altitudeLossIndex = cursor.getColumnIndexOrThrow(TracksColumns.ALTITUDE_LOSS);
        int iconIndex = cursor.getColumnIndexOrThrow(TracksColumns.ICON);

        Track track = new Track(ZoneOffset.ofTotalSeconds(cursor.getInt(startTimeOffsetIndex)));
        TrackStatistics trackStatistics = track.getTrackStatistics();
        if (!cursor.isNull(idIndex)) {
            track.setId(new Track.Id(cursor.getLong(idIndex)));
        }
        if (!cursor.isNull(uuidIndex)) {
            track.setUuid(UUIDUtils.fromBytes(cursor.getBlob(uuidIndex)));
        }
        if (!cursor.isNull(nameIndex)) {
            track.setName(cursor.getString(nameIndex));
        }
        if (!cursor.isNull(descriptionIndex)) {
            track.setDescription(cursor.getString(descriptionIndex));
        }
        if (!cursor.isNull(categoryIndex)) {
            track.setCategory(cursor.getString(categoryIndex));
        }

        if (!cursor.isNull(startTimeIndex)) {
            trackStatistics.setStartTime(Instant.ofEpochMilli(cursor.getLong(startTimeIndex)));
        }
        if (!cursor.isNull(stopTimeIndex)) {
            trackStatistics.setStopTime(Instant.ofEpochMilli(cursor.getLong(stopTimeIndex)));
        }
        if (!cursor.isNull(totalDistanceIndex)) {
            trackStatistics.setTotalDistance(Distance.of(cursor.getFloat(totalDistanceIndex)));
        }
        if (!cursor.isNull(totalTimeIndex)) {
            trackStatistics.setTotalTime(Duration.ofMillis(cursor.getLong(totalTimeIndex)));
        }
        if (!cursor.isNull(movingTimeIndex)) {
            trackStatistics.setMovingTime(Duration.ofMillis(cursor.getLong(movingTimeIndex)));
        }
        if (!cursor.isNull(maxSpeedIndex)) {
            trackStatistics.setMaxSpeed(Speed.of(cursor.getFloat(maxSpeedIndex)));
        }
        if (!cursor.isNull(minAltitudeIndex)) {
            trackStatistics.setMinAltitude(cursor.getFloat(minAltitudeIndex));
        }
        if (!cursor.isNull(maxAltitudeIndex)) {
            trackStatistics.setMaxAltitude(cursor.getFloat(maxAltitudeIndex));
        }
        if (!cursor.isNull(altitudeGainIndex)) {
            trackStatistics.setTotalAltitudeGain(cursor.getFloat(altitudeGainIndex));
        }
        if (!cursor.isNull(altitudeLossIndex)) {
            trackStatistics.setTotalAltitudeLoss(cursor.getFloat(altitudeLossIndex));
        }
        if (!cursor.isNull(iconIndex)) {
            track.setIcon(cursor.getString(iconIndex));
        }
        return track;
    }
/**
     * Creates a {@link Track} from a cursor.
     *
     * @param cursor the cursor pointing to the track
     */
Creates a  Track from a cursor.
@param cursor the cursor pointing to the track
Creates a Track from a cursor . @param cursor the cursor pointing to the track
public static Track createTrack(Cursor cursor) {
        int idIndex = cursor.getColumnIndexOrThrow(TracksColumns._ID);
        int uuidIndex = cursor.getColumnIndexOrThrow(TracksColumns.UUID);
        int nameIndex = cursor.getColumnIndexOrThrow(TracksColumns.NAME);
        int descriptionIndex = cursor.getColumnIndexOrThrow(TracksColumns.DESCRIPTION);
        int categoryIndex = cursor.getColumnIndexOrThrow(TracksColumns.CATEGORY);
        int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME);
        int startTimeOffsetIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME_OFFSET);
        int stopTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STOPTIME);
        int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE);
        int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME);
        int movingTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MOVINGTIME);
        int maxSpeedIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAXSPEED);
        int minAltitudeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MIN_ALTITUDE);
        int maxAltitudeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAX_ALTITUDE);
        int altitudeGainIndex = cursor.getColumnIndexOrThrow(TracksColumns.ALTITUDE_GAIN);
        int altitudeLossIndex = cursor.getColumnIndexOrThrow(TracksColumns.ALTITUDE_LOSS);
        int iconIndex = cursor.getColumnIndexOrThrow(TracksColumns.ICON);
        Track track = new Track(ZoneOffset.ofTotalSeconds(cursor.getInt(startTimeOffsetIndex)));
        TrackStatistics trackStatistics = track.getTrackStatistics();
        if (!cursor.isNull(idIndex)) {
            track.setId(new Track.Id(cursor.getLong(idIndex)));
        }
        if (!cursor.isNull(uuidIndex)) {
            track.setUuid(UUIDUtils.fromBytes(cursor.getBlob(uuidIndex)));
        }
        if (!cursor.isNull(nameIndex)) {
            track.setName(cursor.getString(nameIndex));
        }
        if (!cursor.isNull(descriptionIndex)) {
            track.setDescription(cursor.getString(descriptionIndex));
        }
        if (!cursor.isNull(categoryIndex)) {
            track.setCategory(cursor.getString(categoryIndex));
        }
        if (!cursor.isNull(startTimeIndex)) {
            trackStatistics.setStartTime(Instant.ofEpochMilli(cursor.getLong(startTimeIndex)));
        }
        if (!cursor.isNull(stopTimeIndex)) {
            trackStatistics.setStopTime(Instant.ofEpochMilli(cursor.getLong(stopTimeIndex)));
        }
        if (!cursor.isNull(totalDistanceIndex)) {
            trackStatistics.setTotalDistance(Distance.of(cursor.getFloat(totalDistanceIndex)));
        }
        if (!cursor.isNull(totalTimeIndex)) {
            trackStatistics.setTotalTime(Duration.ofMillis(cursor.getLong(totalTimeIndex)));
        }
        if (!cursor.isNull(movingTimeIndex)) {
            trackStatistics.setMovingTime(Duration.ofMillis(cursor.getLong(movingTimeIndex)));
        }
        if (!cursor.isNull(maxSpeedIndex)) {
            trackStatistics.setMaxSpeed(Speed.of(cursor.getFloat(maxSpeedIndex)));
        }
        if (!cursor.isNull(minAltitudeIndex)) {
            trackStatistics.setMinAltitude(cursor.getFloat(minAltitudeIndex));
        }
        if (!cursor.isNull(maxAltitudeIndex)) {
            trackStatistics.setMaxAltitude(cursor.getFloat(maxAltitudeIndex));
        }
        if (!cursor.isNull(altitudeGainIndex)) {
            trackStatistics.setTotalAltitudeGain(cursor.getFloat(altitudeGainIndex));
        }
        if (!cursor.isNull(altitudeLossIndex)) {
            trackStatistics.setTotalAltitudeLoss(cursor.getFloat(altitudeLossIndex));
        }
        if (!cursor.isNull(iconIndex)) {
            track.setIcon(cursor.getString(iconIndex));
        }
        return track;
    }
public static Track createTrack ( Cursor cursor ) { int idIndex = cursor . getColumnIndexOrThrow ( TracksColumns . _ID ) ; int uuidIndex = cursor . getColumnIndexOrThrow ( TracksColumns . UUID ) ; int nameIndex = cursor . getColumnIndexOrThrow ( TracksColumns . NAME ) ; int descriptionIndex = cursor . getColumnIndexOrThrow ( TracksColumns . DESCRIPTION ) ; int categoryIndex = cursor . getColumnIndexOrThrow ( TracksColumns . CATEGORY ) ; int startTimeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . STARTTIME ) ; int startTimeOffsetIndex = cursor . getColumnIndexOrThrow ( TracksColumns . STARTTIME_OFFSET ) ; int stopTimeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . STOPTIME ) ; int totalDistanceIndex = cursor . getColumnIndexOrThrow ( TracksColumns . TOTALDISTANCE ) ; int totalTimeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . TOTALTIME ) ; int movingTimeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . MOVINGTIME ) ; int maxSpeedIndex = cursor . getColumnIndexOrThrow ( TracksColumns . MAXSPEED ) ; int minAltitudeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . MIN_ALTITUDE ) ; int maxAltitudeIndex = cursor . getColumnIndexOrThrow ( TracksColumns . MAX_ALTITUDE ) ; int altitudeGainIndex = cursor . getColumnIndexOrThrow ( TracksColumns . ALTITUDE_GAIN ) ; int altitudeLossIndex = cursor . getColumnIndexOrThrow ( TracksColumns . ALTITUDE_LOSS ) ; int iconIndex = cursor . getColumnIndexOrThrow ( TracksColumns . ICON ) ; Track track = new Track ( ZoneOffset . ofTotalSeconds ( cursor . getInt ( startTimeOffsetIndex ) ) ) ; TrackStatistics trackStatistics = track . getTrackStatistics ( ) ; if ( ! cursor . isNull ( idIndex ) ) { track . setId ( new Track . Id ( cursor . getLong ( idIndex ) ) ) ; } if ( ! cursor . isNull ( uuidIndex ) ) { track . setUuid ( UUIDUtils . fromBytes ( cursor . getBlob ( uuidIndex ) ) ) ; } if ( ! cursor . isNull ( nameIndex ) ) { track . setName ( cursor . getString ( nameIndex ) ) ; } if ( ! cursor . isNull ( descriptionIndex ) ) { track . setDescription ( cursor . getString ( descriptionIndex ) ) ; } if ( ! cursor . isNull ( categoryIndex ) ) { track . setCategory ( cursor . getString ( categoryIndex ) ) ; } if ( ! cursor . isNull ( startTimeIndex ) ) { trackStatistics . setStartTime ( Instant . ofEpochMilli ( cursor . getLong ( startTimeIndex ) ) ) ; } if ( ! cursor . isNull ( stopTimeIndex ) ) { trackStatistics . setStopTime ( Instant . ofEpochMilli ( cursor . getLong ( stopTimeIndex ) ) ) ; } if ( ! cursor . isNull ( totalDistanceIndex ) ) { trackStatistics . setTotalDistance ( Distance . of ( cursor . getFloat ( totalDistanceIndex ) ) ) ; } if ( ! cursor . isNull ( totalTimeIndex ) ) { trackStatistics . setTotalTime ( Duration . ofMillis ( cursor . getLong ( totalTimeIndex ) ) ) ; } if ( ! cursor . isNull ( movingTimeIndex ) ) { trackStatistics . setMovingTime ( Duration . ofMillis ( cursor . getLong ( movingTimeIndex ) ) ) ; } if ( ! cursor . isNull ( maxSpeedIndex ) ) { trackStatistics . setMaxSpeed ( Speed . of ( cursor . getFloat ( maxSpeedIndex ) ) ) ; } if ( ! cursor . isNull ( minAltitudeIndex ) ) { trackStatistics . setMinAltitude ( cursor . getFloat ( minAltitudeIndex ) ) ; } if ( ! cursor . isNull ( maxAltitudeIndex ) ) { trackStatistics . setMaxAltitude ( cursor . getFloat ( maxAltitudeIndex ) ) ; } if ( ! cursor . isNull ( altitudeGainIndex ) ) { trackStatistics . setTotalAltitudeGain ( cursor . getFloat ( altitudeGainIndex ) ) ; } if ( ! cursor . isNull ( altitudeLossIndex ) ) { trackStatistics . setTotalAltitudeLoss ( cursor . getFloat ( altitudeLossIndex ) ) ; } if ( ! cursor . isNull ( iconIndex ) ) { track . setIcon ( cursor . getString ( iconIndex ) ) ; } return track ; }
Creates a {@link Track} from a cursor.
Creates a { @link Track } from a cursor .