Welcome back, everyone.
We've now got a class that can produce test data for our database.
The next step is to add it to the menu.
We'll do that in main activity
in the on options item selected function.
We added a generate option to the menu a few videos ago.
But we set its show as action attribute to never.
We'll see how to enable it in debug mode in a moment.
First, I'll add the code that creates our TestData.
It's very short.
All we have to do is call the generateTestData function
and pass it the app's content resolver.
To make our menu visible, we enable it in the
oncreate options menu function.
We only want it enabled for debug builds,
so the code to show the menu item is inside an if block.
The compiler is smart enough to realize that this code won't
be executed except in a debug build
and doesn't compile it for a release build.
Unfortunately, as we'll see in a moment,
the code still has to be valid for all builds.
We can now run the app and make sure our TestData Class is working.
Remember that it loops through all the tasks in the database
and creates a random number of timings for each one.
That means you must have some tasks before using theGenerateData option.
So if you haven't got any tasks in your emulator,
add some before continuing.
Okay. Make sure that logcat's open.
Then go to the menu on the app and choose generate data.
We don't get any feedback when the generation is complete.
It's all a bit basic. That's fine.
We're taking steps to ensure that users never get to see this code.
It's just for us when we're testing and debugging the app.
The logcat shows a load of records being created.
We've got the logging from our content provider,
showing each row being added.
I won't do this, but you could go into the terminal
and use SQLite 3 to examine the data
to make sure there have been some timing records inserted.
But that's looking good.
There's a load of insert entries in the logcat
and it looks like the test data class has done its job.
Having test data available is going to make checking our reports a lot easier,
and we'll start creating the report activity next.
Before I do that though,
I want to show you what I mean about debug and release builds
and also explain that comment about debug code
having to be valid even in a release build.
We'll look at that in the next video. I'll see you there.