G'day everyone, welcome back. In the last two videos, we wrote the code to save the
timing data. In this video, we'll make sure it's working. We've written the time
Task function in our viewModel. To use it, we'll call it in the onTaskLong
Click function, in the MainActivityFragment.
Okay, I'll run the app to make sure it works. I'm using an emulator that isn't a
Google Play emulator, which makes checking the database easier, without
having to drag it back to my computer to check it. If you're using a physical
device, you'll have to use the device file explorer to check your database.
We've got a bit more work to do yet, and at the moment, there's no visual
indication when a task is long-tapped. that makes testing interesting.
Fortunately, we've got the logcat. I'll make sure it's visible and clear before continuing.
When I long-tap a task, we get the entries appearing in the logcat.
You should see a new record being inserted into the database on a separate
thread. Switching to the terminal tab, I'll start a shell on the device and
examine the database. When you run sqlite on an emulator, you can't use the
cursor keys to repeat a command. That's mildly annoying, because I want to run
the same query against the timingsTable several times. The sqlite 3
command line lets you specify a query when you run it. It executes the query,
then terminates, which is handy. That means I can repeat the sqlite 3
command, using my up arrow key.
I don't think I've used sqlite 3 three like that before. I can use the
up arrow to repeat the query, without having to type it again.
Alright, there's our new row in the timings Table. Back on the emulator,
I'll long-tap another task. That should update the duration column for the
current task, then add a new row for the new task.
I tapped a few times.
There's the previous row, now with a non-zero duration, and the new records
that were added. When I long-tap the second task again, the app stops timing
and updates the database with the duration. So that's looking good. Well,
it's not looking good, but it's behaving well. At the moment, there's no indication
that a task is being timed. We'll add that in the next video. I'll see you then.