aw-android icon indicating copy to clipboard operation
aw-android copied to clipboard

Location of database

Open kovasap opened this issue 3 years ago • 6 comments

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?

kovasap avatar Apr 19 '21 02:04 kovasap

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.

ErikBjare avatar Apr 19 '21 08:04 ErikBjare

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 avatar Apr 19 '21 15:04 kovasap

Nvm, see https://github.com/ActivityWatch/aw-android/pull/63

kovasap avatar Apr 19 '21 15:04 kovasap

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?

kovasap avatar Apr 19 '21 15:04 kovasap

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?

kanishkarj avatar May 02 '21 19:05 kanishkarj

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 : ).

kovasap avatar May 08 '21 22:05 kovasap