yashsingh1/xdaforums huggingface dataset:
[Amazfit] abelalvesxda:
Tried Export_from_DB.bat and got this:

adbd cannot run as root in production builds

failed to copy '/data/data/com.huami.watch.sport/databases/sport_data.db' to './sport_data.db': Permission denied

What is wrong?

Regards,
[Amazfit] 1immortal:
your phone is rooted or not?
[Amazfit] Diginix:
Just read the error output: "cannot run as root in production builds"

You have a stock ROM with locked bootloader and with this no root permissions. But root is needed to have access to the sport_data.db in Android user data.

There is a possibility to unlock your bootloader. Only you know if it's worth it for you. Soon it will be possible here at XDA: click
[Amazfit] fzelle:
You don't really need root.

As I said there is a version ( actually in the first posting of this thread ) that can get the db via the

android build in backup function.

I put the abe.jar into the archiv and changed the batch to get the data via Backup.

You will get a textscreen on your watch, asking for permission to do the backup.

scroll to the bottom and touch the right button.

It will take some time and then you are good to go.

https://www.dropbox.com/s/xzsd9yriwpha0ol/AmazfitExport.ZIP?dl=1

Edit:

And you need 7zip in c:\program files\7zip or you have to edit the batch for the de-tar
[Amazfit] abelalvesxda:
I will the bootloader unlock.

Thanks!

---------- Post added at 01:25 PM ---------- Previous post was at 01:20 PM ----------

I will try this method. Thanks!
[Amazfit] cresstt2:
This works...tq
[Amazfit] ichanz:
can i use this to backup and restore data, before n after factore reset?
[Amazfit] fzelle:
That is the official Android backup

https://www.technipages.com/how-to-backup-your-entire-android-device

But try it before the reset, I don't know if they have changed something
[Amazfit] poyensa:
Thanks this works for me, to extract TCX (GPX didnt work) from Amazit Watch locked bootloader 1.3.3a (no root OC), so I could manually export the file to Strava. Sync with Strava has stopped since a couple of days ago. I think the problem with Strava appears after APK version 1.7.1

I had a little problem with python to work correctly in W10, needed to add the PATH where pyton was installed in enviroment variable, after that the Export_from_DB.bat worked fine.
[Amazfit] fzelle:
I'm using the gpx export, what is not working?

Any message?
[Amazfit] poyensa:
GPX file content no information (906bytes compared to 819KB for TCX), and when uploaded to strava these messages are shown:

BTW today the APK has synchorized with Strava directly without any trouble, no need to extract data to PC.
[Amazfit] fzelle:
could you pm me the Database ( 7zip ), then I can look what's wrong there.
[Amazfit] cresstt2:
just to let everyone know, i upgraded from latest chinese amazfit android software to the latest english version (1.7.1), and strava sync works again.

On the previous english version, yhe sycn stops working for some reason and I had to resort to using the script here.

anyway..thanks for the script!! I used it to upload like 7 workouts to strava.
[Amazfit] fzelle:
That it's working now after upgrading is just a coincidence.

It wasn't working for me on Sunday ( that's why I changed the script ), and the next time it worked again.

I think that after the other thread ( https://xdaforums.com/smartwatch/amazfit/amazfit-gps-drifting-problem-findout-t3631995 ) Huami did some work with their

upload service ( you don't upload directly to Strava but to Huami and they send the converted Data to Strava ) which then wasn't available at some points.
[Amazfit] slackovic:
I'm not sure if this question should go to this thread, but I don't want to open another one.

Is there a way to recover data to the watch? I accidently reset the watch to factory defaults and now I don't have my activities in the watch. When I paired it the Amazfit app asked me to restore the data, but it restored it to the app. Not to the watch itself.

Poslano sa mog Redmi 3 koristeći Tapatalk
[Amazfit] Diginix:
Without having a backup of /data from the watch, it should be very tricky. The SQlite databases from the watch apps are not the same as that on phone. So, you must build all tables, structures from scratch with the data from the Amazfit app databases. This is hard stuff without a ready for use convert tool.
[Amazfit] slackovic:
Thanks for the info. It sounds pretty complicated and my previous activities are not that important. And I have them in the Amazfit app.

Poslano sa mog Redmi 3 koristeći Tapatalk
[Amazfit] josepmrochera:
Hi, I tried to get the GPX files, however the tool to extract them failed. Please find below the text. Any idea?

*******************************************************

** PGM download sport_data from the Huami watch **

** and export to TCX or GPX **

*******************************************************

.

*******************************************************

** sport_data.db exist in your PC **

*******************************************************

.

*******************************************************

** Do you want download again? press Y/N **

*******************************************************

** and press Enter ** y

*******************************************************

** Conect your watch to PC and press ENTER **

*******************************************************

.

*******************************************************

** Download sport_data.db **

** If is not response, then reconnect your watch. **

*******************************************************

.

List of devices attached

5ee3221c device

adbd cannot run as root in production builds

failed to copy '/data/data/com.huami.watch.sport/databases/sport_data.db' to './sport_data.db': Permission denied

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

The system cannot find the file specified.

*******************************************************

** Download sport_data.db is completed. **

*******************************************************

.

*******************************************************

** Export to TCX press T **

** Export to GPX press G **

*******************************************************

** and press Enter ** g

*******************************************************

** Exporting to GPX **

*******************************************************

.

Traceback (most recent call last):

File "pgm/gpx/amazfit_exporter_cli.py", line 7, in <module>

amazfit_exporter.db_to_gpx(db,dest)

File "C:\Users\JosepMaria\Downloads\Export_Huami_db_to_GPX_TCX\pgm\gpx\amazfit_exporter.py", line 14, in db_to_gpx

cur.execute('SELECT track_id, start_time from sport_summary where type=2 or type=1')

sqlite3.OperationalError: no such table: sport_summary

*******************************************************

** Export to GPX is done **

*******************************************************

.

Press any key to continue . . .​
[Amazfit] jan.stanicek:
Do you have installed PACEfied ROM? It looks that you have not available root permissions...
[Amazfit] fzelle:
As Jan said, you need root for that version to work, you could have read about it just 2 pages back.

I posted a version that uses android backup there.

https://xdaforums.com/showpost.php?p=73037563&postcount=106
[Amazfit] Puzzlehead:
What is your FW version? Maybe you are lock root access.

Odesláno z mého Redmi 3S pomocí Tapatalk
[Amazfit] Puzzlehead:
I inserted to Amazifit Exporter new batch Export_from_DB_using_Backup_of_Watch.bat by Fzelle and edit python for TCX by andree182

See in

https://xdaforums.com/showpost.php?p=73037563&postcount=106
[Amazfit] franx1s:
Hello. Does anyone know how to translate time field in DB? f.e. 1483721953000

EDIT: I found it: http://www.esqsoft.com/javascript_examples/date-to-epoch.htm

http://spreadsheetpage.com/index.php/tip/converting_unix_timestamps/
[Amazfit] giozire:
CAN'T OPEN sport_data.db

Hi!

Did everything like you said and got the .db files inside the app/com... folder but when I try to open the file using db browser it fails:

Could not open database file.

Reason: Invalid file format

help!!! does it have any protection, do I need to root the amazfit pace?

thks
[Amazfit] giozire:
SOLVED...

import pandas as pd

import sqlite3

cnx = sqlite3.connect(‘sport_data.db’)

df = pd.read_sql_query(“SELECT * FROM heart_rate”, cnx)

df.to_csv(‘sport_data.csv’)
[Amazfit] fzelle:
You have seen https://xdaforums.com/showpost.php?p=73961282&postcount=8 ?
[Amazfit] giozire:
Thanks fzelle!
[Amazfit] LorenzZ0:
Where i can find the new version?
[Amazfit] thorsen83:
Hi there

When I try to export my data I don't retrive all the activities. First ten or so are missing. Any idea about that?

Thanks in advance
[Amazfit] fzelle:
Can you pm me the Database, then I can have a look at the data
[Amazfit] Joost39/2:
I use the script included for donwload - it works fine on my Amazfit Pace US nonrooted version - collects all my activities including the indoor ones :D.

I upload the TCX manually to Endomondo - and everything seems fine. (stopped using Strava).
[Amazfit] thorsen83:
That's part of the problem. I still able to see activities prior to August the 2nd in Amazfit App but not in the watch.

How can them have been removed? Is there any way to extract that data from Amazfit App?

Thanks in advance
[Amazfit] ajid1977:
i try export an indoor bike activity. it didn't work. but, as for treadmill running, it's still okey. partly can be exported to strava but not the cadence.

i also having problem with the activity time. it seem to be that they use the sync time and not the activity real time.
[Amazfit] fzelle:
Are you sure the data is erased in the Database and not only not shown on the watch?
[Amazfit] thorsen83:
Hi fzelle

Well, not 100% sure, but quite. The minimum epoch I've found in the database is 1501690118000 (08/02/2017 - MM/DD/YYYY) but in Amazfit App I have activities from 07/11/2017 and I would like to export them (at least, some of them with GPS tracking)

Any idea would be apreciated. Thanks in advance
[Amazfit] fzelle:
Yes, it seems that they delete activities on the watch.

maybe they fear that they run out of space ( ram or sd ).

I can see 30 activities on your watch. I checked my database and there are 30 as well.

But as I only use runtastic ( sync from strava to garmin to runtastic ) I don't care for the data on the watch.
[Amazfit] thorsen83:
The thing is that some of the deleted activities are indoor, so never got exported to Strava. I also tried to delete my Strava account and sync again in order to check if the ones with GPS data were then exported but no luck. It only syncs the latest ones (maybe based on some date param?)

From Amazfit App I only can export a pic of the activity and that's all. Data is there, somewhere, but no luck accessing it
[Amazfit] fzelle:
Have you used https://xdaforums.com/showpost.php?p=73961282&postcount=8

to generate TCX files and upload them to strava?

I have to check if I can somehow get the same done for the Android App.
[Amazfit] thorsen83:
Yes, I jumped from post #8 to #106 and there I downloaded the AmazfitExporter. The Dropbox link from #8 isn't working anymore.

Thanks for trying, man!
[Amazfit] thorsen83:
In case it helps, I've found under /data/com.huami.watch.hmwatchmanager/databases several DBswith info about steps, heart-rate measurements, etc.

Problem is that table on companion-aa.db called sport-detail is empty whereas sport-summary has all my activities info, but summed up.

Anyway, it seems like a good place to start if you want to sport steps data and so.

Regards
[Amazfit] fzelle:
Sorry, the working one is in https://xdaforums.com/showpost.php?p=74009529&postcount=10

I have seen the DB, and they even put some other data in there, ( GPS as csv in one column ).

I will have a look in the evening.
[Amazfit] 5nak3:
[MENTION=289999]fzelle[/MENTION] I know I've already thanked you for the link to the export tool! In fact I've been using it for a few different activities and it works well.

There are a couple things within it that I want to work on so I've taken to modifying the code as I test to see if what I had in mind will work and I think I came across a bug.

Where you set the activities the order at least compared to the 1.3.4f firmware seems a bit off:

In your code you have the following block

if sportType == 1:
activity = "running"
elif sportType == 2:
activity = "walking"
elif sportType ==3:
activity = "trail running"
elif sportType == 4:
activity = "treadmill"
elif sportType == 5:
activity = "bike"
elif sportType == 6:
activity = "eliptical"
elif sportType == 7:
activity = "indoor bike"
else:
activity = "unknwon"

I've been registering my activities as elliptical and when I process the export I always end up with files tagged for indoor bike. A small re-order and the export is being tagged correctly.

if sportType == 1:
activity = "running"
elif sportType == 2:
activity = "walking"
elif sportType ==3:
activity = "treadmill"
elif sportType == 4:
activity = "bike"
elif sportType == 5:
activity = "indoor bike"
elif sportType == 6:
activity = "trail run"
elif sportType == 7:
activity = "eliptical"
else:
activity = "unknwon"

I probably should add that I've not had a chance to test every activity my code ordering is based on the order the activities appear on the watch.
[Amazfit] thorsen83:
I'm sorry, where did you find that column? I'm checking the database but no luck.

Thanks!
[Amazfit] fzelle:
In the Table sport_detail I have 35 entries and they habe for ex in the field longitude_latitude all coordinates as a semicolon delimited string.

But every entry has gps coordinates, so I think that will also not really work for you.

[MENTION=4853114]5nak3[/MENTION]:

Thanks, I changed it in my sources as well and reuploaded the file.
[Amazfit] thorsen83:
Do you mean in the database I uploaded or yours? I'm not seeing them in mine, so I supose is yours what you're talking about.

There's no problem in only having 35 activities and all with GPS data, at least there more than the 30 limit found.
[Amazfit] fzelle:
Yes, in my database.

As I have everything on Strava, I don't care really what's on the watch.

And as I hate indoor sport ( can't stand treadmills ) the python script was just something to play around with.
[Amazfit] thorsen83:
Yeah, I know what you mean. Anyway, is there any chance to resync activities with Strava? Once synced with one account they never sync again so if you have deleted the activity on Strava or removed the account there's apparently no way to resync.

I've no idea if its based on a param or in the column "synced" con the db. I retrieve values 3072 for synced activities and 3 for non synced but if I update the table and try to resync I got an app FC and everything restoring as before the update, but no resync.
[Amazfit] fzelle:
I just checked something.

The 35 entries that I have in my phone DB, are those where I checked the data on the phone.

I just picked a few others and now I have 42.

So if you go into the app, and pick every activity, wait until it is fully loaded and after that exit the app and backup the db again,

you might have data in sport_detail.

If that's the case we might get somewhere.
[Amazfit] thorsen83:
I've just tried that and, certainly, by accesing activities on the app they get reflected on the DB, but I have no idea how to build a GPX or TCX file from that data. Could you guide me?

Thanks!
[Amazfit] fzelle:
sure.

I will try to get a prototype done this evening ( after work ).

As my main language I use C# so if you have a windows PC it will work directly.

Otherwise I have to look for an alternative.
[Amazfit] thorsen83:
I'm more like a Linux guay, but don't worry, I'll make it work! Really appreciated, man!
[Amazfit] fzelle:
Looked at it yesterday, the gps coordinates are in a (not so ) funny format.

Linux is also no problem, Mono is still running there.

I will have a look at .NET Core, that is running on Windows/Linux/Mac OS.

As we only need a cmdline sw, that should be ok.

Maybe get a shot at it tonight.
[Amazfit] fzelle:
[MENTION=3224238]thorsen83[/MENTION]

Send you PM
[Amazfit] Gerii:
How did you access that folder? Via adb backup or did you need root?
[Amazfit] thorsen83:
I did it whith root access but I don't know if there's any other way that doesn't need it.
[Amazfit] fzelle:
You can use the std Android Backup for that.

https://xdaforums.com/showpost.php?p=74009529&postcount=10

If you download that python script, you will have a batch called Export_from_phone.bat

After that you need to unpack the tar file with for example 7zip
[Amazfit] jps1x2:
Hi,

After several months of study Android app development and study of dissasemble/decompile Android apps i have developed one Mifit app version that allows export to TCX format my running workouts.

I have created one Telegram channel to update and publish frequently my mod when new versions of original Mifit app will be published:

https://t.me/MifitTcxExport

Regards
[Amazfit] passosk58:
The Mifit modified app have a problem.

When I export activities in TCX the data of velocity and altitude is very very bad.

The velocity is allways the same in all activity.

The altitude is completly inacurate and diferent of data in watch..

Can you verify? Is possible export to gpx?

Enviado do meu Redmi+4 através de Tapatalk

---------- Post added at 11:39 PM ---------- Previous post was at 11:35 PM ----------

The data of velocity and altitude in tcx file exported is bad and totally diferent from data in watch.

The velocity is same in all activity and altitude is very inacurate from - 2000 to + 2500 in a real altitude from 500 to 1000...

Enviado do meu Redmi+4 através de Tapatalk
[Amazfit] jps1x2:
New versions of MifitTcxExport availables

Hi,

Now there are new versions of my mod in my Telegram Channel correcting export problems and allowing export to gpx format too, try it and tell me if it works ok. Big altitude differences are not caused by my mod, i am only extracting altitude data from Mifit database and using it to create tcx and gpx files. In last versions i am using my Google Maps Api Key and maps are showing ok.
[Amazfit] Joost39/2:
I´ve used this exporter for my Pace so I could upload the TCX file to Endomondo - but now I have the Amazfit Stratos/Sports Watch 2 - and it does not work nor export the DB anymore.

Would it be possible to make it work plz....
[Amazfit] Joost39/2:
Could you make it work with the new Amazfit Stratos? Plz., plz.!:good: I´ve used your version for the Amazfit Pace for a long time.....
[Amazfit] Joost39/2:
It seems that in Amazfit Stratos the sport_data.db is named something else.

C:\adb>adb devices

List of devices attached

aa8c0a1a device

C:\adb>adb pull /data/data/com.huami.watch.sport/databases/sport_data.db

adb server is out of date. killing...

* daemon started successfully *

remote object '/data/data/com.huami.watch.sport/databases/sport_data.db' does not exist ?

C:\adb>adb backup -f /export_data.ab -noapk com.huami.watch.sport

Now unlock your device and confirm the backup operation.

The command works on the watch but theres no output?
[Amazfit] fzelle:
Then we need to find the name of the new apk that is been used

adb shell pm list packages

Then we can try to backup the "right" one
[Amazfit] Joost39/2:
I´ve uploaded the "working version" for Amazfit Stratos - it exports TCX files to PC and I can upload them to Endomondo, Runkeeper etc.

BUT:

1. The distance plus maps are missing in the TCX - but cadence, pulse etc. seems to be correct on Endomondo.

2. Activitynames are wrong because of all the new sportactivities in the new Stratos - I don¨t know the numbers for the correct listing.
[Amazfit] fzelle:
Good to know.

Did you have the pace?

How is the new HR monitor ( because of the raised housing) ??
[Amazfit] Joost39/2:
1. It seems that they changed the way the collect the data - they now have a third option i apps drawer; f - it collects the detailed distance and altitude etc.

I give up and use the GPX export function in the watch for Run, Walk, Bike - and don´t use the watch ind the gym anymore.

2. Yes I think the HR monitor is doing a better job because of the raised housing!
[Amazfit] IvanSokolovic:
The easiest way to export .gpx file from Amazfit Pace

After doing the sync. sport data of your activity in Strava application you can go to your Strava personal page to your Dishbord to analyze your activity. On the left side of the screen under Overview you can find an tool icon named Actions. Open and find Export GPX. Click on it. The .gpx file will be stored in your download folder. That's all folks! Enjoy!
[Amazfit] fards:
[MENTION=4948642]jps1x2[/MENTION]

Do you ever work on the beta versions of the mi fit app? I follow the telegram channel.

I really like this mod you've done, but the 3.3.2.2 beta seems a bit more reliable than the 330 version.
[Amazfit] jps1x2:
Hi!

Normally i only mod stable versions because oficial Beta versions have bricked some Bips and in my channel i decided to publish only mods of stable versions.

Normally Beta versions of Mifit app contain beta versions of firmware. You can install this beta from apkmirror, your Bip will be updated and later install MifitTcxExport version without firm update to use export functions again.
[Amazfit] jps1x2:
[MENTION=8823785]Proxor-s[/MENTION]

I can't reply your private message, i write here my reply about Mifit app time shift, sorry by the off-topic:

I examined a lot of tracks too and checked it with excel adding seconds to starting time. At the beginning of my mod 0 was 1 but 2 or 3 can't be replaced by 1 in all situations. If i export one cycling activity time shifts are bigger (2,3,4 or more) and starting increment is not only 30 or 31. I use same algorythm to export running and cycling activity and i add real values (0, 1, 2, ...) to increment time, sometimes i have duplicated epoch on trackpoints on my tcx/gpx files (when adding 0) but it is minimal and then i can use same algorythm to export cycling an running. Tested on several of my activities and if i add 1 on 0 shift, total time of activity was bigger than real time used.

I worked very hard adjusting time shifts trying to distribute increments correctly and now it is the better it could be for me because i am calculating pauses too to parse laps and it is more dificult to calculate and adjust. Amazfit Bip is not 100% accurate saving time increments as you can see.

Regards!
[Amazfit] exdeathpl:
Is there someone who can update a "sport_type" in TCX python file "amazfit_exporter.py" ?

Why endomondo cant read distance parameter from TCX file?
[Amazfit] nhedgehog:
I did some research to readjust the activities on the Stratos (Running a Stratos ROM 2.3.0.8 on the Pace). To make it easier to adapt in the future I added the actitvity number to the output file too.

Here is my adapted amazfit_exporter.py. Further on I adapted the time output since even with the tc value changed to my timezone, I couldn't get the real timecode into the tcx. I switched from "utcfromtimestamp" to "fromtimestamp", which seems to give me the right time.

This is the version I changed:

https://xdaforums.com/showpost.php?p=75587415&postcount=167
[Amazfit] Joost1001:
I got an empty folder when running the file, looks like the file is missing the table sport_summary. A sport_data table has been downloaded, but changing the Python script to look for sport_data does not help. Anyone got a suggestion what might go wrong here?

Running ROM 2.3.2.7 on my Stratos.

*******************************************************

Time zone is now: 0h

Traceback (most recent call last):

File "pgm/tcx/amazfit_exporter_cli.py", line 33, in <module>

amazfit_exporter.db_to_tcx(db,dest,upd_begtime,tz)

File "C:\Users\User\Downloads\AmazfitExport_Stratos\AmazfitExport\pgm\tcx\amazfit_exporter.py", line 16, in db_to_tcx

cur.execute('SELECT track_id, start_time, type, content from sport_summary where track_id >'+ str(begtime) + '')

sqlite3.OperationalError: no such table: sport_summary

*******************************************************

** Export to TCX is done **

*******************************************************