Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location of database #62

Open
kovasap opened this issue Apr 19, 2021 · 6 comments
Open

Location of database #62

kovasap opened this issue Apr 19, 2021 · 6 comments

Comments

@kovasap
Copy link

kovasap commented Apr 19, 2021

Is the database saved as a sqlite file somewhere on the device I could get access to? I'm looking for a way to automatically backup my usage data from my phone without having to manually use the export feature. I have another app that lets me sync specific directories on my phone to the cloud; I'd like to feed it the AW data directory.

Does this make sense or is there a better way to achieve what I'm looking for?

@ErikBjare
Copy link
Member

ErikBjare commented Apr 19, 2021

The Android app stores the SQLite file in its assigned data directory, however this directory is likely protected from being accessed by other apps (for security reasons). However, if you've rooted your phone it should be easy to access, and you might also be able to access it with adb.

@kovasap
Copy link
Author

kovasap commented Apr 19, 2021

Ah ok I see. I see that AW also has a directory in /storage/emulated/0/Android/data/net.activitywatch.android, but it is empty. Could you point me to the place in the code where the database file location is set (or is auto set by default)? I think for me it would be easiest to change this in a aw-android fork (or contribute it back if you would like). I can't root my current phone as I use it for work as well : (.

@kovasap
Copy link
Author

kovasap commented Apr 19, 2021

Nvm, see #63

@kovasap
Copy link
Author

kovasap commented Apr 19, 2021

If it makes more sense, I could also try to accomplish this by adding a auto-export feature to the server, which would work for all AW platforms. What do you think?

@kanishkarj
Copy link

Hi, it might also work if the app could auto-expory to Dropbox or some cloud storage once a day I guess. I don't think we would need realtime sync, we just need the ability to consolidate data from all devices in one location right?

@kovasap
Copy link
Author

kovasap commented May 8, 2021

I was hoping to fix this problem for myself by using adb to make just the acitivitywatch data directory readable by all, but this also requires root : (.

I did discover that running adb backup net.activitywatch.android when the device is connected to the PC with developer mode enabled produces a backup.ab file. You can then extract this file with ( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) | tar xfvz - to get at all the data activitywatch stores, including the sqlite.db file. Perhaps there is a way to run this command on the phone itself via LADB, but this seems to require Android 11 for the WiFi debugging, which I don't have. If this is possible, you could periodically run the backup command to get the data exported automatically to a readable dir on your phone, then sync that dir to wherever.

Anyway, the best solution I think would be to either add an option to have activitywatch automatically export, or have the syncing feature implemented so that this data is pushed to my pc and I can just get it from there. Or you could just root your phone : ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants