1
00:00:00,270 --> 00:00:06,110
So now are we to actually create our difference to our database in firebase.

2
00:00:06,270 --> 00:00:07,670
So how we can do that.

3
00:00:07,680 --> 00:00:15,780
So in order to actually learn how to actually send data to the database in firebase First we need to

4
00:00:15,780 --> 00:00:17,470
actually read the documentation.

5
00:00:17,520 --> 00:00:17,980
Right.

6
00:00:18,120 --> 00:00:22,940
So let me actually open the browser here and here.

7
00:00:23,040 --> 00:00:24,830
Just click on this overview here.

8
00:00:24,940 --> 00:00:25,420
OK.

9
00:00:25,470 --> 00:00:31,500
Or you can actually click on firebase or you can actually just open another tab and then go to the firebase

10
00:00:31,830 --> 00:00:32,850
website.

11
00:00:32,850 --> 00:00:41,220
So here I'm going to click on this or that of you here and now as you can see here we have these actually

12
00:00:41,250 --> 00:00:50,070
these tutorials and these are actually the documentations that we can use in order to learn to actually

13
00:00:50,070 --> 00:00:51,680
work with the firebase.

14
00:00:51,720 --> 00:00:56,370
So because we want to actually work with the database as you can see here we have this database here

15
00:00:56,550 --> 00:01:02,670
and it says store and simple data in real time across all connected clients.

16
00:01:02,670 --> 00:01:07,030
So here just click on this little more here click on it.

17
00:01:07,230 --> 00:01:09,750
And now we are guided to the documentation.

18
00:01:09,750 --> 00:01:10,370
Right.

19
00:01:10,380 --> 00:01:16,820
Or I can actually click on this firebase here at the top left and then as you can see this is the virus

20
00:01:16,860 --> 00:01:17,880
Web site.

21
00:01:18,090 --> 00:01:24,900
And now this is actually the initial page that is going to be shown to you when you actually open the

22
00:01:24,900 --> 00:01:27,040
file by Smith firebase website.

23
00:01:27,060 --> 00:01:30,090
And now at the top you can see it says Ducs right.

24
00:01:30,090 --> 00:01:36,990
I can click on the stocks here and then as you can see here we have firebase firebase by platform and

25
00:01:36,990 --> 00:01:38,910
then here just click on this get started.

26
00:01:38,910 --> 00:01:39,600
Got it.

27
00:01:40,970 --> 00:01:45,360
And here as you can see this is actually firebase documentation.

28
00:01:45,450 --> 00:01:48,060
And now as you can see here we chose Android.

29
00:01:48,060 --> 00:01:48,670
Right.

30
00:01:48,720 --> 00:01:57,270
And here click on these real time database here and then click on get started as you can see here.

31
00:01:57,390 --> 00:01:58,850
Just click on this get started.

32
00:01:58,950 --> 00:02:03,060
So realtime database Android gets started right.

33
00:02:03,120 --> 00:02:05,990
And then here it says that you need to connect up to firebase.

34
00:02:06,000 --> 00:02:13,540
So we already connected up to fire rates and we add the he added the real time database to our application.

35
00:02:13,560 --> 00:02:19,570
So as you can see here we actually configured the database rules.

36
00:02:19,610 --> 00:02:19,880
OK.

37
00:02:19,890 --> 00:02:22,740
As you can see we actually can figure out the database tool.

38
00:02:22,800 --> 00:02:29,940
So let let me open this tap here and if I click on this database here and then if I click on the rules

39
00:02:29,940 --> 00:02:33,920
tab here you can see that we actually configured the database route.

40
00:02:33,930 --> 00:02:39,780
So we actually allow the users that are not authenticated to use this database.

41
00:02:39,780 --> 00:02:40,270
Right.

42
00:02:40,350 --> 00:02:42,930
But using this double equal operators here.

43
00:02:42,930 --> 00:02:43,800
Right.

44
00:02:43,830 --> 00:02:46,490
So let me ask you to open this up here again.

45
00:02:46,560 --> 00:02:50,310
And now it's time to write data to the database.

46
00:02:50,310 --> 00:02:50,950
Right.

47
00:02:51,360 --> 00:02:57,180
So now it says that to retrieve an instance of your database using to get instance.

48
00:02:57,180 --> 00:03:01,260
So first of all we need to actually get an instance of our database.

49
00:03:01,260 --> 00:03:06,280
This is the first step and reference the location you want to write to.

50
00:03:06,570 --> 00:03:08,330
So first we need to get the instance.

51
00:03:08,370 --> 00:03:13,580
And then if we need to actually get the reference to the location we want to write to.

52
00:03:13,710 --> 00:03:15,360
So let's see how we can do that.

53
00:03:15,360 --> 00:03:20,530
First of all as you can see there is a comment here and it says write a message to the database.

54
00:03:20,660 --> 00:03:21,440
Right.

55
00:03:21,690 --> 00:03:24,480
And it says firebase database.

56
00:03:24,510 --> 00:03:27,480
So here it is actually creating a variable.

57
00:03:27,780 --> 00:03:30,380
And the name of this variable is database right.

58
00:03:30,380 --> 00:03:38,040
Did they touch type of this variable is firebase database and then it put an assignment operator here.

59
00:03:38,370 --> 00:03:44,130
And as you can see here it actually referred to the name of this firebase database here firebase database

60
00:03:44,250 --> 00:03:45,740
that instance.

61
00:03:46,080 --> 00:03:52,800
So it actually refers to the name of this firebase database class and called the Smurfette get instance

62
00:03:52,860 --> 00:03:54,300
on this class.

63
00:03:54,300 --> 00:03:54,790
Right.

64
00:03:54,810 --> 00:04:00,660
So in this way we can actually get an instance of our database and we can assign that instance to our

65
00:04:00,660 --> 00:04:06,030
variable which is of type database which is of type firebase database and its name is database so these

66
00:04:06,030 --> 00:04:12,740
database here now holds an instance of their firebase database.

67
00:04:12,750 --> 00:04:17,550
So let's actually first of all let's just copy this line of code here.

68
00:04:17,970 --> 00:04:25,500
And let's actually open the Android studio and now let's actually first inside these uncreate Mefford

69
00:04:25,590 --> 00:04:28,700
we can actually just paste this line of code here.

70
00:04:28,830 --> 00:04:34,440
So now as you can see we have actually an instance of the firebase database.

71
00:04:34,440 --> 00:04:35,890
So this is the first step.

72
00:04:35,940 --> 00:04:36,310
Right.

73
00:04:36,330 --> 00:04:51,860
So now let me create a comment first so that for writing data to database.

74
00:04:52,210 --> 00:04:52,850
Right.

75
00:04:52,900 --> 00:04:54,320
So this is the first step.

76
00:04:54,400 --> 00:04:58,400
And now let's actually open our web browser again here.

77
00:04:58,480 --> 00:05:05,470
It says that we need to actually get a reference here as you can see we need to get a reference to the

78
00:05:05,470 --> 00:05:09,030
actually location that we want to write to.

79
00:05:09,100 --> 00:05:09,760
Right.

80
00:05:09,760 --> 00:05:12,700
So now let me actually open this tap here.

81
00:05:12,700 --> 00:05:16,280
Firebase concert and click on the state tab here as you can see.

82
00:05:16,600 --> 00:05:21,970
And now as you can see if you have this up actually this is our fiber's instance right.

83
00:05:22,510 --> 00:05:27,220
And we just want you to get a reference to the location that we want to write to.

84
00:05:27,220 --> 00:05:34,870
So first let's actually open these tab here and now as you can see it actually created a variable of

85
00:05:34,900 --> 00:05:38,210
type database reference and its name is Mailer.

86
00:05:38,530 --> 00:05:45,340
And then it put for an assignment operator here and then it referred to the name of this database instance.

87
00:05:45,370 --> 00:05:49,650
So database that gets reference right message.

88
00:05:49,930 --> 00:05:58,710
So first let's actually go inside our Android studio and now we want to actually get our reference to

89
00:05:58,710 --> 00:06:00,820
the location that you want to write the data.

90
00:06:01,080 --> 00:06:05,980
So the data type is going to be database reference as you can see here right.

91
00:06:06,000 --> 00:06:12,450
So I can just type in database reference and the name is going to be my ref.

92
00:06:12,720 --> 00:06:17,910
As you can see here so that the same name here you can actually name it up in other names.

93
00:06:17,910 --> 00:06:24,660
You can actually give it another name but I chose this name here myself and then I put an assignment

94
00:06:24,690 --> 00:06:25,910
operator here.

95
00:06:25,980 --> 00:06:26,540
Right.

96
00:06:26,760 --> 00:06:33,740
And then I refer to the name of this database instance that I created in number 25 dot.

97
00:06:33,960 --> 00:06:39,660
So now you can see here we have some if it's right or you want to choose this method gets reference

98
00:06:39,840 --> 00:06:43,220
from you l right through a fence.

99
00:06:43,380 --> 00:06:47,950
So just select this method here and then person enter key on your keyboard.

100
00:06:48,610 --> 00:06:56,340
And now inside Apprentice's as you can see it says that we need to actually put on not Knol screen value.

101
00:06:56,530 --> 00:06:59,310
So we need to put up two double quotes here.

102
00:07:00,230 --> 00:07:01,900
And inserted double quotes.

103
00:07:01,910 --> 00:07:03,300
We need to put a u r l.

104
00:07:03,410 --> 00:07:07,130
So what is that you are less actually open the web browser again.

105
00:07:07,370 --> 00:07:09,690
And let's click on this tab here.

106
00:07:10,340 --> 00:07:12,090
And as you can see here we have this.

107
00:07:12,140 --> 00:07:12,820
And here.

108
00:07:12,830 --> 00:07:19,470
So just click on it you are here and let's click on it and then click on copy right.

109
00:07:19,490 --> 00:07:23,780
Or if you are using a Windows machine you can actually hold the control key and then press on the letter

110
00:07:23,900 --> 00:07:25,090
c key and your keyboard.

111
00:07:25,160 --> 00:07:29,960
And if you are using a Mac you can actually hold the comment here and then press on the leaders key

112
00:07:29,960 --> 00:07:35,750
on your keyboard and then now that we have actually copied this you Arel It's actually open the Android

113
00:07:35,760 --> 00:07:38,120
stood you again and inside double quotes.

114
00:07:38,240 --> 00:07:44,630
Just paste this value right and then put a semicolon at the end of your statement.

115
00:07:44,660 --> 00:07:51,950
So now we actually got a reference to our location that we want to write the data and that location.

116
00:07:51,950 --> 00:07:54,350
Is this actually this you are.

117
00:07:54,360 --> 00:07:55,560
All right.

118
00:07:55,580 --> 00:08:02,030
So now if I click on this you are on here and if I actually for example add another radio for example

119
00:08:02,060 --> 00:08:11,500
person persons and they can go as you can see now it says that we have inside this database.

120
00:08:11,570 --> 00:08:14,330
We have this person's right.

121
00:08:14,420 --> 00:08:16,830
This is the location that we can actually write our data.

122
00:08:17,030 --> 00:08:17,450
Right.

123
00:08:17,630 --> 00:08:23,740
So now let me actually just delete this persons here and then click on go.

124
00:08:23,750 --> 00:08:29,950
So here we have this instance box 38 or dash C 59 D-B colon null.

125
00:08:29,960 --> 00:08:31,350
And it says The value is null.

126
00:08:31,400 --> 00:08:33,410
So this is the key as you can see here.

127
00:08:33,410 --> 00:08:38,870
Disvalue is the key and this value is that we have no value right.

128
00:08:39,050 --> 00:08:42,430
So now if I click on it nothing happens right.

129
00:08:42,440 --> 00:08:45,540
So as you can see here we have this plus button.

130
00:08:45,830 --> 00:08:48,320
And here we have this delete button right.

131
00:08:48,600 --> 00:08:53,480
And if I actually hover over this plus button here it says add child.

132
00:08:53,510 --> 00:09:00,900
So let's click on it and now it says that you can actually just create a name of value.

133
00:09:00,950 --> 00:09:07,640
So as you can see here let me actually click on this delete button here delete button here and now if

134
00:09:07,640 --> 00:09:15,410
I click on the plus button here it says that we can actually add a child to our database instance right.

135
00:09:16,380 --> 00:09:22,040
So now if I actually click on it we can actually add a child so what it's going to be the key.

136
00:09:22,380 --> 00:09:30,550
So the name is going to be for example the name is going to be box or name.

137
00:09:30,570 --> 00:09:31,310
Right.

138
00:09:31,350 --> 00:09:34,050
And I must actually put a value here.

139
00:09:34,140 --> 00:09:36,270
So the value can be for example.

140
00:09:36,270 --> 00:09:43,790
So now let me add this extra W so the value can be for example my Buxar.

141
00:09:43,830 --> 00:09:45,000
So this is the name right.

142
00:09:45,000 --> 00:09:45,880
This is the value.

143
00:09:46,080 --> 00:09:51,460
And if we click on this ad here now we have a child here.

144
00:09:51,740 --> 00:09:57,860
And it's key is box name and it's value is my boxer right.

145
00:09:57,870 --> 00:10:01,480
I can actually create another child as you can see here.

146
00:10:01,490 --> 00:10:03,410
I can actually create an adult child here.

147
00:10:03,410 --> 00:10:14,010
So if I click on it and here I can say for example Boxer for example power and the value can be for

148
00:10:14,010 --> 00:10:18,080
example of one thousand or ten thousand and click on.

149
00:10:18,670 --> 00:10:26,100
And now we have another child as you can see here and it's in it's KEAYS box of power and its value

150
00:10:26,100 --> 00:10:27,250
is ten thousand.

151
00:10:27,510 --> 00:10:34,060
Right so now as you can see here the value here is of type string.

152
00:10:34,100 --> 00:10:37,720
And the value here is of type integer right.

153
00:10:37,820 --> 00:10:47,580
So now if I click on this up plus here and now I can actually create another category in order to hold

154
00:10:47,820 --> 00:10:48,970
the kickboxers.

155
00:10:49,140 --> 00:10:54,680
So for the name I can just type in cheek boxers right.

156
00:10:54,690 --> 00:10:55,020
Here.

157
00:10:55,050 --> 00:11:01,050
I don't want to assign a value because this is going to be a category that I can actually contain the

158
00:11:01,320 --> 00:11:03,040
values of the kickboxers.

159
00:11:03,180 --> 00:11:06,450
So and here as you can see we have this A-plus right.

160
00:11:06,480 --> 00:11:13,200
Just click on it at child and now as you can see here we have a category that can actually contain the

161
00:11:13,200 --> 00:11:14,370
other values.

162
00:11:14,370 --> 00:11:20,100
So for example teach boxers and the name is going to be for example that she is going to be kickboxer

163
00:11:21,780 --> 00:11:29,960
name and the value can be the value can be for example my Keech boxer.

164
00:11:32,220 --> 00:11:32,700
Right.

165
00:11:32,790 --> 00:11:35,000
And then I can click on that.

166
00:11:35,040 --> 00:11:40,540
So here as you can see we have actually another chapter called The kickboxers that can actually hold

167
00:11:40,560 --> 00:11:42,700
this child kickboxer name.

168
00:11:42,750 --> 00:11:44,080
And this is the value.

169
00:11:44,430 --> 00:11:49,730
And in this way we can actually create lots of children and lots of parents.

170
00:11:49,770 --> 00:11:57,210
It doesn't really matter how you manage the database it just depends on your own actually a way of structuring

171
00:11:57,210 --> 00:11:58,040
the database.

172
00:11:58,140 --> 00:11:59,040
Right.

173
00:11:59,070 --> 00:12:06,360
So for now just look at this structure as you can see we can actually say we can do the same thing that

174
00:12:06,360 --> 00:12:13,410
we did here from our Java code inside our Java code by writing Java code so we can do the same thing

175
00:12:13,410 --> 00:12:13,990
here.

176
00:12:14,220 --> 00:12:15,540
So let's see how we can do that first.

177
00:12:15,540 --> 00:12:17,570
Let's actually delete these values here.

178
00:12:17,790 --> 00:12:23,100
As you can see if I click on the delete button of window opens and then you can actually click on it

179
00:12:24,300 --> 00:12:29,440
and then there's actually did it this one and then delete this one right.

180
00:12:29,490 --> 00:12:32,400
So now we have only this instance right.

181
00:12:32,430 --> 00:12:34,160
This is going to be the patent.

182
00:12:34,440 --> 00:12:39,430
And now this actually you can actually call this also a root.

183
00:12:39,480 --> 00:12:40,800
Right.

184
00:12:40,800 --> 00:12:43,640
Let's actually go to our Android studio.

185
00:12:43,830 --> 00:12:50,810
So now that we have actually an instance of type database and now that we have a reference to actually

186
00:12:50,820 --> 00:12:53,820
did the location that we want to write the data.

187
00:12:54,290 --> 00:12:56,380
Let's actually open our web browser again.

188
00:12:56,520 --> 00:12:58,000
And let's actually open this.

189
00:12:58,100 --> 00:13:05,900
Let's actually just open this tap here again and now it says my if so this is the first step might if

190
00:13:05,900 --> 00:13:06,980
that set value.

191
00:13:06,990 --> 00:13:08,120
Hello voting.

192
00:13:08,520 --> 00:13:14,400
So now let's actually copy this line of code here and let's get you to go inside our Android studio.

193
00:13:15,390 --> 00:13:21,050
And inside the unclick listener of this button I want the data to be returned to the database when the

194
00:13:21,050 --> 00:13:22,400
user clicks on the button.

195
00:13:22,400 --> 00:13:28,730
So inside the uncle listen of the database as you can see here in say the uncle Smurfette of there is

196
00:13:29,270 --> 00:13:32,110
unclick listener I can just paste this value.

197
00:13:32,330 --> 00:13:38,930
So now as you can see here we have actually an error and it says valuable myself is accessed from within

198
00:13:39,020 --> 00:13:42,160
Inul class needs to be declared final.

199
00:13:42,170 --> 00:13:44,980
So here we can in line number 27.

200
00:13:44,990 --> 00:13:50,020
We can actually declare this valuable as final so that we can actually make it a constant.

201
00:13:50,120 --> 00:13:50,590
Right.

202
00:13:50,810 --> 00:13:53,540
And now as you can see here the error is gone.

203
00:13:53,570 --> 00:13:59,170
So now let's actually run our project here initialising AEB.

204
00:13:59,460 --> 00:14:04,330
And then you can actually choose the virtual device and then click on OK.

205
00:14:04,760 --> 00:14:06,260
So now let's wait.

206
00:14:06,720 --> 00:14:11,300
So now as you can see here our application is actually running on the emulator.

207
00:14:11,340 --> 00:14:14,250
So now let me make this emulator actually bigger.

208
00:14:14,390 --> 00:14:15,760
We're just trying to get here.

209
00:14:16,730 --> 00:14:22,010
And now if I click on the spot in here send the data to say well let's actually click on this button

210
00:14:22,040 --> 00:14:23,090
and see what happens.

211
00:14:23,090 --> 00:14:30,500
Just click on it and now let's actually open our web browser and then just click on this tab here and

212
00:14:30,500 --> 00:14:36,650
now as you can see here we have this key which is the location that you want to light that data right.

213
00:14:36,650 --> 00:14:43,240
So as you can see here we chose this you r l as the location that we want to light it up.

214
00:14:43,340 --> 00:14:50,960
So when I actually go to this you are well we actually guided to this actually the page to this instance

215
00:14:51,250 --> 00:14:54,610
and it we connected the right value to this parent.

216
00:14:54,650 --> 00:14:57,250
So this is going to be the key and this is going to be the value.

217
00:14:57,290 --> 00:15:01,410
And here you can see that we have this key and the value is Hello world.

218
00:15:01,640 --> 00:15:07,090
So now if we you to go to the Android studio here I can show you that first.

219
00:15:07,250 --> 00:15:10,540
We have a reference to their database instance.

220
00:15:10,730 --> 00:15:14,270
And then we have a reference to the location that we want to write the data.

221
00:15:14,270 --> 00:15:20,690
So this is the location that actually got us to this page that is valuable to this instance.

222
00:15:20,840 --> 00:15:26,180
And then when I say my left right might it refers to this instance right.

223
00:15:26,180 --> 00:15:28,040
Might have that set value.

224
00:15:28,490 --> 00:15:29,360
Hello world.

225
00:15:29,360 --> 00:15:32,430
Here we are setting the value here right.

226
00:15:32,480 --> 00:15:33,180
Hello world.

227
00:15:34,210 --> 00:15:38,240
So this is just a simple application right.

228
00:15:38,260 --> 00:15:40,630
We're going to actually make it more complex.

229
00:15:40,660 --> 00:15:43,690
But for now I just want you to get the idea right.

230
00:15:43,870 --> 00:15:52,020
And if I actually go to the open this tap here and as you can see we are just here right to your database.

231
00:15:52,110 --> 00:15:55,030
So now we want you to make it more complex.

232
00:15:55,080 --> 00:15:55,700
Right.

233
00:15:55,740 --> 00:16:00,790
So now let me actually just close this tab here and now we have this value.

234
00:16:00,840 --> 00:16:07,340
Let's actually go back to an android studio and here instead of hello world as you can see here are

235
00:16:07,390 --> 00:16:11,400
you going to actually put the value of these it takes to the set.

236
00:16:11,640 --> 00:16:19,200
So just delete this hello world here I just referred to the name of this EDT value dot get text dot

237
00:16:19,650 --> 00:16:24,180
2st so we can actually assign a think value here right.

238
00:16:24,180 --> 00:16:25,920
Because this sets value here.

239
00:16:25,920 --> 00:16:31,560
Let me actually just again refer to the name of this might have thought sets value as you can see it

240
00:16:31,560 --> 00:16:34,950
is set value needs a value of type Object.

241
00:16:35,010 --> 00:16:38,740
And this thing value can be actually an object right.

242
00:16:38,970 --> 00:16:45,280
So let's actually run our project now and let's wait a little bit here.

243
00:16:45,690 --> 00:16:50,310
So as you can see here our application is actually running on this emulator.

244
00:16:50,550 --> 00:16:56,020
So now as you can see if I click on the spot in here let's see what happens send the data to server.

245
00:16:56,310 --> 00:17:01,590
And let's actually open the browser here and now as you can see here we have an empty value.

246
00:17:01,590 --> 00:17:02,210
Why.

247
00:17:02,220 --> 00:17:07,590
Because we haven't actually assigned a value to this edit text so let's actually write a value here

248
00:17:07,620 --> 00:17:08,710
inside this as it takes.

249
00:17:08,820 --> 00:17:18,930
So here I can just typing proxying is a martial art.

250
00:17:19,240 --> 00:17:19,770
Right.

251
00:17:19,990 --> 00:17:22,390
And then click on send data to server.

252
00:17:22,820 --> 00:17:26,800
And now as you can see it says boxing is a martial art.

253
00:17:26,800 --> 00:17:28,080
Right.

254
00:17:28,120 --> 00:17:32,980
So it is actually sending this data that I put here to the server.

255
00:17:32,980 --> 00:17:34,870
So let's go back to what Android studio

256
00:17:37,370 --> 00:17:40,900
and now I want to actually make it a little more complex.

257
00:17:40,940 --> 00:17:44,020
So let's actually go to activity underline minute example.

258
00:17:44,120 --> 00:17:48,110
So here we need to actually make a design to use an interface here again.

259
00:17:48,380 --> 00:17:53,600
So let's actually just select this button here and then press on delete key on your keyboard.

260
00:17:53,600 --> 00:17:59,440
And then here we can actually say this componentry section at the bottom left here.

261
00:17:59,480 --> 00:18:03,950
You can actually just say this componentry section it can select this editrix and then press on delete

262
00:18:03,950 --> 00:18:05,420
key on your keyboard.

263
00:18:05,750 --> 00:18:08,650
So now we wanted to design the user interface here again.

264
00:18:08,750 --> 00:18:10,520
So let's see how we can do that.

