Welcome back, everyone.
The changes to our app provider class are easy.
We've already got most of the code in there.
We just have to uncomment it, and make a couple of adjustments.
First, the constants for the build UriMatcher function to use.
I'll delete the task durations ID constant.
We're not going to access this table by ID.
We just don't have any need to query for a single row.
We don't have the get id and build URI from ID functions
in the contracts class either,
just like we don't have them in the current timing contract class that we copied.
Next, we can uncomment the lines in the build URI matcher function.
When we first created this AppProvider class many videos ago,
we added the constants for the durations.
They followed the same pattern as the other constants,
but we don't need the ability to query either of our views by ID
that's not necessarily true of all views by the way but it's often the case.
Views that join two or more tables
are unlikely to have a unique ID for each row.
A task durations view, certainly doesn't have a unique ID.
In that case, why have we got a constant
and UriMatch entry to allow a query by ID.
I made this point when we created the current timing view,
but it's worth repeating.
Boilerplate code, like these contract classes
and the entries here in our app provider class can save a lot of typing time.
But don't just copy and paste without thinking.
I'll delete that line that we're not going to use
and tidy up that unneeded constant declaration.
The next change is in the query method.
I'll uncomment the code we want
and delete the boilerplate code for retrieving a row by its ID.
And finally, the getType method. Once again,
there's a line that we don't need, and I'll delete it.
We don't make any changes to the update and insert methods
because we won't be changing the database via the view.
It's only used for reading the data. Views in SQLite
are read-only.
All right. We should be able to run the app
and have the database update itself.
There's no errors so that's looking good.
The SQL to produce the view is logged in our logcat.
If you get any problems, copy the SQL from there
and compare it to the comment in our code,
that'll make spotting any errors much easier.
I'll stop this video here. In the next video,
we'll check the database and also test the upgrade from version 1
to version 3 of the database.
I'll see you in that one.