earlybird software, llc

Android Contraction Timer DB

January 21, 2011 9:34PM[link]

Update: The 1.2 version of the app now lets you browse the history of contractions, so this may not be necessary anymore. However, if you want to export the data off the device for backup or more complicated analysis, this may still be useful.

I don't (yet) have an export function in the Contraction timer, however my intention is not to keep you from accessing your own data. In the meantime, you may find this script which generates a csv file handy. The data is stored in an sqlite3 DB, with a simple schema (a contraction table with columns for the starttime and stoptime which are in seconds since epoch, and a column inprogress which is 0 or 1). You may want to modify it to calculate the duration, spacing between contractions, etc. Let me know if anyone writes a better script and I'll post it here for all to use. Thanks! -Mike

#! /usr/bin/python

# File is located at:
#     /data/data/com.earlybirdsoftware.contractiontimer/files/ctxtimer.db
# With the emulator, I use this command:
# adb pull /data/data/com.earlybirdsoftware.contractiontimer/files/ctxtimer.db .
# My phone isn't rooted; let me know if that's not where it is on the device

import sqlite3
import time

con = sqlite3.connect('ctxtimer.db')
cur = con.cursor()

f = open('ctxtimer.csv', 'w')
cur.execute('select starttime, stoptime, inprogress from contraction')
for row in cur.fetchall():
    # row[0] is start time in seconds since epoch
    # row[1] is stop time in seconds since epoch
    # row[2] is 0/1 whether it's in progress
    # So you can massage these however you want ;-)
    f.write('%s,%s,%d\n' % (time.ctime(row[0]), time.ctime(row[1]), row[2]))


History | Main Page

Copyright (C) 2011-2013 Earlybird Software LLC