[Samsung Gear S] iNDEX3:
Hi!

1) Pull from phone file /opt/usr/apps/com.samsung.shealth/data/.shealth.db

2) Open this file in SQLiteStudio

3) Open editor (Alt+E)

4) Add in editor the following:

select exerciseId, datetime(substr(startTimeStamp,1,10), 'unixepoch') as startTime from shealth_exercise_history order by startTimeStamp;

Select all (Crtl+A) and execute (F9).

You'll see all your trainings. Remember the value "exerciseId" of the desired training. For example "5".

5) Replace the contents of the editor by doing the following:

select '<?xml version="1.0" encoding="UTF-8" standalone="no" ?><gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1" xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxpx="http://www.garmin.com/xmlschemas/PowerExtension/v1" creator="Samsung Gear S with Barometer" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackStatsExtension/v1 http://www8.garmin.com/xmlschemas/TrackStatsExtension.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd http://www.garmin.com/xmlschemas/PowerExtension/v1 http://www.garmin.com/xmlschemas/PowerExtensionv1.xsd"><metadata><link href="http://www.index3.ru"><text>iNDEX3</text></link><time>'||strftime('%Y-%m-%dT%H:%M:%SZ', datetime(substr(gh.startTimeStamp,1,10), 'unixepoch'))||'</time></metadata><trk><name>'||datetime(substr(gh.startTimeStamp,1,10), 'unixepoch')||' Auto</name><extensions><gpxx:TrackExtension><gpxx:DisplayColor>Cyan</gpxx:DisplayColor></gpxx:TrackExtension></extensions><trkseg>' as gps
from shealth_exercise_history gh where gh.exerciseId=XX
union all
select
'<trkpt lat="'||g.latitude||'" lon="'||g.longitude||'"><ele>'||g.altitude||'</ele><time>'||strftime('%Y-%m-%dT%H:%M:%SZ', datetime(substr(g.timeStamp,1,10), 'unixepoch'))||'</time><extensions><gpxtpx:TrackPointExtension><gpxtpx:hr>'||h.heartrate||'</gpxtpx:hr></gpxtpx:TrackPointExtension></extensions></trkpt>' as gpx
from shealth_exercise_gps_info g
left join (
select gt.timeStamp as g_timeStamp
, (select max(ht.timeStamp) from shealth_exercise_hrm_logging ht where ht.timeStamp<=gt.timeStamp and ht.exerciseId=gt.exerciseId) as h_timeStamp
, gt.exerciseId
from shealth_exercise_gps_info gt
) tsm on tsm.g_timeStamp=g.timeStamp and tsm.exerciseId=g.exerciseId
left join shealth_exercise_hrm_logging h on h.timeStamp=tsm.h_timeStamp
where g.latitude <> 200 and g.exerciseId=XX
union all
select '</trkseg></trk></gpx>';

Find in text "exerciseId=XX" and replace to value ("XX") to the value of your exerciseId ("5").

Select all (Crtl+A) and execute (F9).

6) Save result in txt file with extension ".gpx".

Enjoy :)

I have collected all scripts into one package:

1) Unzip and run "0.start.bat"

2) Enjoy x2 :)

Update:

v1.1 Added option "Save all trainings"

[DOWNLOAD v1.1]