1
00:00:04,700 --> 00:00:06,200
Welcome back, everyone.

2
00:00:07,000 --> 00:00:09,800
The changes to our app provider class are easy.

3
00:00:10,500 --> 00:00:12,800
We've already got most of the code in there.

4
00:00:13,100 --> 00:00:16,460
We just have to uncomment it, and make a couple of adjustments.

5
00:00:17,450 --> 00:00:22,050
First, the constants for the build UriMatcher function to use.

6
00:00:23,850 --> 00:00:27,210
I'll delete the task durations ID constant.

7
00:00:27,870 --> 00:00:30,470
We're not going to access this table by ID.

8
00:00:31,070 --> 00:00:34,070
We just don't have any need to query for a single row.

9
00:00:34,950 --> 00:00:39,050
We don't have the get id and build URI from ID functions

10
00:00:39,050 --> 00:00:40,750
in the contracts class either,

11
00:00:41,150 --> 00:00:44,850
just like we don't have them in the current timing contract class that we copied.

12
00:00:49,350 --> 00:00:53,950
Next, we can uncomment the lines in the build URI matcher function.

13
00:00:57,950 --> 00:01:02,450
When we first created this AppProvider class many videos ago,

14
00:01:02,850 --> 00:01:05,250
we added the constants for the durations.

15
00:01:05,750 --> 00:01:08,350
They followed the same pattern as the other constants,

16
00:01:08,750 --> 00:01:12,950
but we don't need the ability to query either of our views by ID

17
00:01:13,250 --> 00:01:17,350
that's not necessarily true of all views by the way but it's often the case.

18
00:01:18,150 --> 00:01:20,750
Views that join two or more tables

19
00:01:20,750 --> 00:01:23,950
are unlikely to have a unique ID for each row.

20
00:01:24,250 --> 00:01:28,250
A task durations view, certainly doesn't have a unique ID.

21
00:01:28,750 --> 00:01:31,750
In that case, why have we got a constant

22
00:01:31,750 --> 00:01:35,010
and UriMatch entry to allow a query by ID.

23
00:01:35,410 --> 00:01:38,910
I made this point when we created the current timing view,

24
00:01:39,160 --> 00:01:40,360
but it's worth repeating.

25
00:01:41,260 --> 00:01:44,560
Boilerplate code, like these contract classes

26
00:01:44,560 --> 00:01:49,550
and the entries here in our app provider class can save a lot of typing time.

27
00:01:50,210 --> 00:01:52,510
But don't just copy and paste without thinking.

28
00:01:53,170 --> 00:01:55,370
I'll delete that line that we're not going to use

29
00:01:55,870 --> 00:01:58,770
and tidy up that unneeded constant declaration.

30
00:02:02,570 --> 00:02:04,930
The next change is in the query method.

31
00:02:05,430 --> 00:02:07,530
I'll uncomment the code we want

32
00:02:07,830 --> 00:02:11,730
and delete the boilerplate code for retrieving a row by its ID.

33
00:02:22,430 --> 00:02:26,330
And finally, the getType method. Once again,

34
00:02:26,330 --> 00:02:29,230
there's a line that we don't need, and I'll delete it.

35
00:02:39,930 --> 00:02:43,590
We don't make any changes to the update and insert methods

36
00:02:43,990 --> 00:02:46,790
because we won't be changing the database via the view.

37
00:02:47,390 --> 00:02:51,590
It's only used for reading the data. Views in SQLite

38
00:02:51,890 --> 00:02:52,890
are read-only.

39
00:02:53,250 --> 00:02:55,750
All right. We should be able to run the app

40
00:02:56,110 --> 00:02:58,110
and have the database update itself.

41
00:03:02,010 --> 00:03:04,210
There's no errors so that's looking good.

42
00:03:05,090 --> 00:03:08,090
The SQL to produce the view is logged in our logcat.

43
00:03:08,490 --> 00:03:11,690
If you get any problems, copy the SQL from there

44
00:03:12,050 --> 00:03:14,050
and compare it to the comment in our code,

45
00:03:14,450 --> 00:03:16,810
that'll make spotting any errors much easier.

46
00:03:17,800 --> 00:03:21,000
I'll stop this video here. In the next video,

47
00:03:21,250 --> 00:03:25,550
we'll check the database and also test the upgrade from version 1

48
00:03:25,550 --> 00:03:27,150
to version 3 of the database.

49
00:03:28,050 --> 00:03:29,150
I'll see you in that one.

