1
00:00:00,450 --> 00:00:06,950
So now let's actually scroll to the top here and here inside our main activity class.

2
00:00:07,020 --> 00:00:09,990
I'm going to actually declare and other three invaluable.

3
00:00:09,990 --> 00:00:18,720
So here just type in strange and here the name of this string value but is a computer or you can say

4
00:00:18,720 --> 00:00:21,990
unique computer ID.

5
00:00:22,320 --> 00:00:22,800
OK.

6
00:00:22,890 --> 00:00:24,670
You need computer 80.

7
00:00:24,810 --> 00:00:30,540
So as you can see inside our class main activity class we created the bell which is of pipes.

8
00:00:30,870 --> 00:00:34,580
And the name of this variable is unique computer ID.

9
00:00:34,590 --> 00:00:37,810
So now let's actually scroll down here.

10
00:00:38,040 --> 00:00:44,660
So let's actually go after the Indian curly brace of the Smurfette of this uncreate method.

11
00:00:44,880 --> 00:00:46,250
And inside this class.

12
00:00:46,260 --> 00:00:52,220
So as you can see here this is the ending curly brace of this class and here this is the ending calibers

13
00:00:52,230 --> 00:00:53,630
of this uncreate method.

14
00:00:53,640 --> 00:01:00,240
So before the end of this class and inside this class inside the curly braces of this class I'm going

15
00:01:00,240 --> 00:01:07,030
to actually paste in some lines of code here and then I'm going to explain to you what's going on here.

16
00:01:07,080 --> 00:01:11,670
So as you can see here these are the lines of code that I pasted here.

17
00:01:11,910 --> 00:01:16,280
So we have a method and the access modifier of the Smurfette is private.

18
00:01:16,290 --> 00:01:19,010
The return type of this method is void.

19
00:01:19,050 --> 00:01:23,820
So as you can see here when I say that the axis modifier of this method is private I mean that this

20
00:01:23,820 --> 00:01:26,730
method is only accessible inside this class.

21
00:01:26,730 --> 00:01:29,950
So you already know about access modifiers in Java.

22
00:01:30,300 --> 00:01:35,270
And here we say that the return type of the term type of this method is void and dismissed.

23
00:01:35,340 --> 00:01:37,080
This means that this method is going to return.

24
00:01:37,080 --> 00:01:39,480
Nothing is going to just do something right.

25
00:01:39,550 --> 00:01:41,580
It's not going to return anything.

26
00:01:41,820 --> 00:01:42,400
OK.

27
00:01:42,870 --> 00:01:49,970
And then the name of this method is produce a new computer and put it in the database.

28
00:01:50,010 --> 00:01:56,250
So the job of this method is to create a new computer object and to put it into the database in the

29
00:01:56,280 --> 00:01:58,640
server right on the server.

30
00:01:58,710 --> 00:02:03,140
So as you can see here this method actually accepts some arguments.

31
00:02:03,510 --> 00:02:10,720
The first argument as you can see here is of type string and the name of this argument is computer name.

32
00:02:10,740 --> 00:02:16,070
The second argument of this method is actually the computer power which is of type integer.

33
00:02:16,110 --> 00:02:22,350
The first argument of this method is actually computer speed which is again of type integer.

34
00:02:22,410 --> 00:02:27,930
The fourth argument of this method is actually computer RAM which is of integer.

35
00:02:28,200 --> 00:02:31,640
And here we have computer screen which is of type string.

36
00:02:32,010 --> 00:02:38,630
And we have computer keyboard which is a unit of papes trained and we have computer CPQ which is after

37
00:02:38,660 --> 00:02:39,580
high street.

38
00:02:39,870 --> 00:02:45,000
So now let's actually go inside the curly braces off the Smurfette And let's see what's going on here

39
00:02:45,750 --> 00:02:52,050
inside the Smurfit as you can see we have this statement and this statement here is saying that text

40
00:02:52,080 --> 00:03:00,570
U-2s so the text utility is actually a class in Java that we are going to use in order to actually do

41
00:03:00,630 --> 00:03:02,720
something with our texts.

42
00:03:02,810 --> 00:03:10,650
So the utility class is going to actually give us some methods in order to actually do something in

43
00:03:10,650 --> 00:03:16,840
order to check whether for example this unique computer ID variable is empty or not.

44
00:03:17,130 --> 00:03:23,160
So we can use this class in order to check this here in order to check that with this unique computer

45
00:03:23,160 --> 00:03:28,800
ID variable which we created inside this class inside me and like if the glass is empty or not.

46
00:03:28,830 --> 00:03:30,350
So now let me scroll to the top here.

47
00:03:30,360 --> 00:03:36,900
As you can see inside this class we created we actually declared this variable which is of types 3 in

48
00:03:36,990 --> 00:03:40,050
unique computer ID and we didn't initialize it yet.

49
00:03:40,080 --> 00:03:40,760
Right.

50
00:03:40,760 --> 00:03:46,830
And now as you can see here inside the Smurfette inside this method you use on your computer and put

51
00:03:46,830 --> 00:03:47,850
it in the database.

52
00:03:47,970 --> 00:03:50,720
Is it saying that it takes you to use that is empty.

53
00:03:50,820 --> 00:03:53,810
So this class takes you to is going to check by this.

54
00:03:53,830 --> 00:03:59,430
But by using this method it's going to check that whether this unique computer ID is valuable is empty

55
00:03:59,430 --> 00:04:00,210
or not.

56
00:04:00,210 --> 00:04:00,660
Right.

57
00:04:00,930 --> 00:04:08,130
And if this expression evaluates to TRUE this means that if the value of this unique computer ID valuable

58
00:04:08,180 --> 00:04:13,590
is actually empty right then it's going to go inside the curly braces of this method and it's going

59
00:04:13,590 --> 00:04:19,710
to execute this line of what here is going to actually assign a value to this unique computer ID so

60
00:04:19,740 --> 00:04:27,720
unique computer ID assignment operator and we are actually referencing our database so you already know

61
00:04:27,840 --> 00:04:34,140
that this database reference valuable is actually holding a reference to the computers category into

62
00:04:34,140 --> 00:04:35,540
the database.

63
00:04:35,670 --> 00:04:36,370
Right.

64
00:04:36,450 --> 00:04:42,190
So you need computer ID assignment operator database or friends that push.

65
00:04:42,330 --> 00:04:47,820
So you know that when I call to push my faith here on our reference it's going to actually create a

66
00:04:47,820 --> 00:04:49,750
unique ID.

67
00:04:49,800 --> 00:04:50,390
Right.

68
00:04:50,640 --> 00:04:56,070
So when you call the push method on your reference it's going to create a unique key or unique a unique

69
00:04:56,100 --> 00:04:59,930
ID for or actually reference.

70
00:04:59,960 --> 00:05:06,200
Here we are calling this method get ciii an undisputed truth can actually get that value that that unique

71
00:05:06,410 --> 00:05:13,070
random ID is going to get that key and it's going to assign that key to this unique computer ID so that

72
00:05:13,070 --> 00:05:14,580
she is going to be off the street.

73
00:05:14,600 --> 00:05:15,160
Right.

74
00:05:15,200 --> 00:05:20,460
Which is actually an object so we can assign it to this unique computer ID which is off the street.

75
00:05:20,630 --> 00:05:21,620
Right.

76
00:05:21,770 --> 00:05:28,770
And now as you can see here we have these lines of code here in line number one hundred and sixty two.

77
00:05:29,090 --> 00:05:33,290
We have created an object of type computer class.

78
00:05:33,590 --> 00:05:39,020
So if we actually go inside this computer class here you can see that we have these instance variables

79
00:05:39,380 --> 00:05:45,890
computer name computer power computer speed computer ram computer screen computer keyboard and computer

80
00:05:45,890 --> 00:05:46,450
CPQ.

81
00:05:46,460 --> 00:05:48,950
These are the instant Swabia bells of this computer.

82
00:05:48,950 --> 00:05:49,530
Right.

83
00:05:49,850 --> 00:05:57,650
And we have these empty constructor which we needed which it is important that we actually put this

84
00:05:57,650 --> 00:05:59,770
into a constructor here.

85
00:06:00,140 --> 00:06:06,210
And we also have this constructor that is going to initialize our instance variables.

86
00:06:06,320 --> 00:06:07,370
Right.

87
00:06:07,370 --> 00:06:15,430
So you know about these kinds of constructors in Java and as you can see here we have these methods

88
00:06:15,470 --> 00:06:20,510
or these getters in order to actually get the values of our instance variables.

89
00:06:20,510 --> 00:06:24,460
So for example computers will compute return computer CPQ.

90
00:06:24,590 --> 00:06:25,670
Right.

91
00:06:25,670 --> 00:06:32,140
So inside is main activity that Java class as you can see here here here inline number of 162.

92
00:06:32,180 --> 00:06:38,000
We created an object OFF-SIDE computer assignment operator new computer.

93
00:06:38,000 --> 00:06:42,840
So as you can see here we are actually creating a new instance of type computer class.

94
00:06:43,160 --> 00:06:48,850
And here we are going to assign that instance to this computer invaluable right.

95
00:06:48,880 --> 00:06:50,360
This is actually a about right.

96
00:06:50,390 --> 00:06:57,020
And here after the assignment operator here you are creating an instance of type computer class and

97
00:06:57,020 --> 00:06:59,780
then we can actually be assigned this instance to this variable.

98
00:06:59,780 --> 00:07:05,120
So whenever that you want to actually ferde to this instance I can just refer to this name here to the

99
00:07:05,120 --> 00:07:06,460
name of this value.

100
00:07:07,250 --> 00:07:12,080
So again computer computer assignment operator new computer.

101
00:07:12,200 --> 00:07:17,420
And here we are using that constructor that is going to initialize our instance variables.

102
00:07:17,450 --> 00:07:21,430
So as you can see here this method you use in your computer and put it in the database method.

103
00:07:21,440 --> 00:07:23,870
This method has some arguments right.

104
00:07:23,870 --> 00:07:28,450
So by using these arguments I can initialize this instance.

105
00:07:28,580 --> 00:07:34,010
So for the first argument I passed this computer name which is of types 3 and for the second argument

106
00:07:34,030 --> 00:07:36,960
I passed the computer power for the first argument.

107
00:07:37,010 --> 00:07:43,580
I passed the computer speed for the forth argument I passed the computer RAM and here I passed the computer

108
00:07:43,580 --> 00:07:47,110
screen computer keyboard and computer CPQ.

109
00:07:47,330 --> 00:07:54,300
So you have created an instance of type computer class by using these arguments of this method.

110
00:07:54,410 --> 00:07:55,370
Right.

111
00:07:55,430 --> 00:08:00,470
So then that I call this method and then I actually passed these values to this method is going to actually

112
00:08:00,470 --> 00:08:04,190
create a new instance of type computer class for us.

113
00:08:04,190 --> 00:08:05,250
Right.

114
00:08:05,360 --> 00:08:12,230
And here in line number one hundred sixty four as you can see I am referring to this database reference.

115
00:08:12,290 --> 00:08:12,980
Right.

116
00:08:12,980 --> 00:08:19,390
So this database reference has already a reference to the computers category.

117
00:08:19,400 --> 00:08:24,890
So if I actually scroll to the top here and go inside these uncreate Smurfit as you can see in line

118
00:08:24,890 --> 00:08:30,280
number 66 as you can see here we are actually creating a reference to the computers category.

119
00:08:30,280 --> 00:08:36,260
So that's why I said that these these databases are friends is what is holding a reference to these

120
00:08:36,260 --> 00:08:37,910
computers category.

121
00:08:37,970 --> 00:08:39,460
So let's scroll down here.

122
00:08:39,590 --> 00:08:43,900
So now I say database or France that child.

123
00:08:43,990 --> 00:08:52,160
And here I specifying the key right the name of this child the key unique computer ID as you can see

124
00:08:52,160 --> 00:08:52,990
here.

125
00:08:53,000 --> 00:09:00,390
So the key is this one right Junichi computer ID dot sits value.

126
00:09:00,530 --> 00:09:02,520
Computer.

127
00:09:02,640 --> 00:09:03,360
Right.

128
00:09:03,410 --> 00:09:08,710
So when I say sit around your computer as you can see here this is actually an object of type computer

129
00:09:08,720 --> 00:09:09,630
right.

130
00:09:09,680 --> 00:09:13,930
So this unique computer idea is going to be actually up.

131
00:09:14,240 --> 00:09:15,330
Category.

132
00:09:15,380 --> 00:09:15,800
Right.

133
00:09:15,800 --> 00:09:21,380
So we have actually a reference to the computers category and here as you can see here in line number

134
00:09:21,380 --> 00:09:29,870
one hundred and fifty eight we are creating a unique ID a unique ID that is randomly created and it

135
00:09:29,870 --> 00:09:35,090
is not going to be the same as any other ideas that are going to be created by the firebase.

136
00:09:35,090 --> 00:09:41,550
So when I say database reference that push is going to actually create a unique ID for me right dot

137
00:09:41,740 --> 00:09:47,870
get key is going to actually get that ID and is going to sign that ID to this unique computer ID which

138
00:09:47,870 --> 00:09:48,770
is of type string.

139
00:09:48,860 --> 00:09:55,640
So now this unique computer Id actually holds that unique ID that is created by the firebase then I

140
00:09:55,640 --> 00:09:58,440
call this push method is going to create that ID.

141
00:09:58,460 --> 00:10:00,240
And here we are getting that.

142
00:10:00,260 --> 00:10:07,240
And we are assigning that key to this unique computer ID in low number of 164 as you can see here I

143
00:10:07,240 --> 00:10:09,620
am saying that database reference.

144
00:10:09,950 --> 00:10:15,980
So this database reference is actually holding our reference to the computers category right.

145
00:10:16,340 --> 00:10:20,850
And here I am specifying the child of that can computers Kathakali.

146
00:10:20,990 --> 00:10:27,290
So the child of that can computers category is going to be unique computer ID right.

147
00:10:27,890 --> 00:10:34,070
So now we have our computers theoretically and the child of that computers category has this.

148
00:10:34,460 --> 00:10:36,870
She has this unique computer ID.

149
00:10:37,160 --> 00:10:40,770
And here we are saying sets value computer.

150
00:10:41,120 --> 00:10:47,780
So this means that is going to actually again treat this Junichi computer ID as a category because we

151
00:10:47,790 --> 00:10:49,480
are passing this object here.

152
00:10:49,490 --> 00:10:50,020
Right.

153
00:10:50,210 --> 00:10:55,930
So now let me actually to go inside the computer class as you can see here we have this instance variables

154
00:10:55,940 --> 00:10:56,300
right.

155
00:10:56,300 --> 00:11:02,150
For example computer name computer power computer speed computer ram computer screen computer keyboard

156
00:11:02,180 --> 00:11:03,690
and computer CPQ.

157
00:11:04,010 --> 00:11:10,820
So when I pass an object to our category here as you can see when I pass an object to our category for

158
00:11:10,820 --> 00:11:18,480
example this one unit computer ID is going to actually put that object with those names and values.

159
00:11:19,270 --> 00:11:21,790
Write is going to for example create a name.

160
00:11:21,910 --> 00:11:27,210
For example the name is computer name and the value and the value is going to be the value that we passed

161
00:11:27,210 --> 00:11:29,180
through this method to this method here.

162
00:11:29,200 --> 00:11:33,800
As you can see so now when we run a project I'll talk more about that later.

163
00:11:33,910 --> 00:11:38,860
And it will make sense but for now just know that we are saying that it is an offense that child the

164
00:11:38,860 --> 00:11:40,560
child is unique computer ID.

165
00:11:40,840 --> 00:11:44,440
And it's going to actually treat this unique computer ID as a category.

166
00:11:44,440 --> 00:11:45,120
Why.

167
00:11:45,280 --> 00:11:53,180
Because we are sitting on the computer object to this unique computer ID that object has keys and names.

168
00:11:53,440 --> 00:11:56,930
So now when I run my project you will see how this works.

169
00:11:57,460 --> 00:12:02,380
And here as you can see in line number of one hundred and sixty six we are calling and other them if

170
00:12:02,380 --> 00:12:06,060
it change the text of send or update button.

171
00:12:06,070 --> 00:12:08,000
According to the situation.

172
00:12:08,020 --> 00:12:10,570
So now let me show you the emulator here.

173
00:12:10,720 --> 00:12:15,030
As you can see let me just make this virtual keyboard disappear.

174
00:12:15,040 --> 00:12:20,830
So as you can see here we have this edit text and the user is supposed to actually enter some values

175
00:12:20,830 --> 00:12:26,660
here and when the user just click on this send button here it can actually send this data to the set

176
00:12:26,670 --> 00:12:26,820
right.

177
00:12:26,840 --> 00:12:27,610
Right.

178
00:12:27,940 --> 00:12:34,870
But after that I want to actually allow the user to update those data are right.

179
00:12:35,020 --> 00:12:40,270
And then when I want to actually update those data I can actually hear change the takes of this button

180
00:12:40,540 --> 00:12:42,000
to update data.

181
00:12:42,160 --> 00:12:45,450
So that's why I actually created this method here.

182
00:12:45,450 --> 00:12:48,490
I actually put this fit but we haven't still created this method.

183
00:12:48,670 --> 00:12:51,920
And that's why you can see that this method is actually in red.

184
00:12:52,060 --> 00:12:54,400
Change the text of sent or update button.

185
00:12:54,400 --> 00:12:55,940
According to the situation.

186
00:12:55,960 --> 00:13:01,780
So after the end in calibrates of the Smurfette Let's actually create the Smurfit here.

187
00:13:01,780 --> 00:13:08,530
Here I can say private and here I can say void and then I can actually first with the name of the Smurfette

188
00:13:08,770 --> 00:13:13,430
change the takes of send or update Potten according to the situation.

189
00:13:13,630 --> 00:13:18,370
And then I put a pair of parenthesis here and then I open and close this method by using these curly

190
00:13:18,370 --> 00:13:19,080
braces.

191
00:13:19,330 --> 00:13:21,750
And now as you can see here the error is gone right.

