1
00:00:00,330 --> 00:00:06,210
High students in this theater are we going to go ahead and create another Android application that actually

2
00:00:06,210 --> 00:00:11,150
connects to the firebase in order to retrieve data up from the server.

3
00:00:11,190 --> 00:00:13,160
So let's create an android studio project.

4
00:00:13,170 --> 00:00:19,060
So just click on this start in your Android studio project and then for the application name just a

5
00:00:19,060 --> 00:00:25,690
pin here app 6 the free dash retrieving data from firebase.

6
00:00:25,980 --> 00:00:32,640
And here you can specify the company domain package name and he can specify the project location and

7
00:00:32,640 --> 00:00:41,340
then click on next and here choose Apr. 19 Android 4.4 chitchat for the minimum scaped for phone and

8
00:00:41,340 --> 00:00:43,880
tablet and then click on next.

9
00:00:44,010 --> 00:00:48,460
And he had to choose the activity next and he had to change anything.

10
00:00:48,500 --> 00:00:53,910
The Actually the activity name should be main activity and generate lay out foil as you can see here

11
00:00:54,140 --> 00:01:00,320
lay out name should be activity underlined main and it says back for backwards compatibility apcupsd.

12
00:01:00,360 --> 00:01:03,400
So make sure that also text box is actually checked on.

13
00:01:03,750 --> 00:01:05,560
And then click on finish.

14
00:01:05,880 --> 00:01:09,350
So now as you can see here it's going actually create the project for us.

15
00:01:09,360 --> 00:01:11,460
It's going to set the project.

16
00:01:12,100 --> 00:01:17,750
And now as you can see here the project is actually created.

17
00:01:17,790 --> 00:01:22,540
So now let me actually close this window here and now.

18
00:01:22,590 --> 00:01:26,930
First of all I need to actually connect my app to death firebase.

19
00:01:27,000 --> 00:01:30,840
So in order to do that let me ask you to open my web browser.

20
00:01:31,110 --> 00:01:37,560
So here as you can see I opened my web browser and I actually entered this you are elde firebase that

21
00:01:37,560 --> 00:01:38,520
Google dot com.

22
00:01:38,540 --> 00:01:43,620
I am actually guided to this page and here as you can see you need to be signed in into your G-mail

23
00:01:43,620 --> 00:01:44,080
account.

24
00:01:44,130 --> 00:01:49,910
And then here you can actually click on this go to console here click click on this go to cancel.

25
00:01:50,300 --> 00:01:54,540
And now let's actually open our Android studio here.

26
00:01:54,650 --> 00:01:56,050
Just click on Tools.

27
00:01:56,150 --> 00:02:01,400
So make sure that your Android studio is actually the latest version of Android studio 2.2.

28
00:02:01,400 --> 00:02:02,160
Right.

29
00:02:02,180 --> 00:02:06,340
And then click on Tools and then here click on firebase.

30
00:02:06,710 --> 00:02:15,200
And now as you can see here just click on these real time database here and now click on Save and retrieve

31
00:02:15,200 --> 00:02:16,030
data.

32
00:02:16,430 --> 00:02:19,880
So first of all we need to connect our application to the firebase.

33
00:02:19,880 --> 00:02:26,310
So here click on this button connect to fight fire race and then it's going to actually start connecting.

34
00:02:26,480 --> 00:02:28,360
The application is set up.

35
00:02:28,400 --> 00:02:33,130
Number the free retrieving data from firebase to the firebase database.

36
00:02:33,140 --> 00:02:35,280
So let's actually wait a little bit here.

37
00:02:35,660 --> 00:02:38,170
So now here is the window opened.

38
00:02:38,270 --> 00:02:38,830
OK.

39
00:02:39,020 --> 00:02:41,530
And it says create new firebase project.

40
00:02:41,540 --> 00:02:46,750
So here click on Connect to firebase.

41
00:02:47,030 --> 00:02:52,700
And here we should wait a little bit and here at the top it says Firebrace connecting app to Firebrace

42
00:02:52,820 --> 00:02:53,340
right.

43
00:02:54,260 --> 00:03:00,810
So this is actually a message that's that the Android studio is showing us.

44
00:03:00,920 --> 00:03:03,550
And now as you can see here it says connected.

45
00:03:03,550 --> 00:03:04,110
Right.

46
00:03:04,330 --> 00:03:09,040
So now here we need to actually just do this second step.

47
00:03:09,040 --> 00:03:12,060
And it says at the real time database to your app.

48
00:03:12,130 --> 00:03:17,840
So just click on the spot in here at the real database at the realtime database to your app.

49
00:03:18,040 --> 00:03:23,330
And here this window opens and then here you just need to click on accept changes.

50
00:03:23,950 --> 00:03:26,150
And again we should actually wait a little bit here.

51
00:03:27,590 --> 00:03:29,900
So now as you can see here everything is ready.

52
00:03:29,900 --> 00:03:30,590
Right.

53
00:03:30,650 --> 00:03:35,300
So now let's actually close these assistant here.

54
00:03:35,510 --> 00:03:40,760
So just click on this panel here assistant and now this assistant is actually collapsed.

55
00:03:40,760 --> 00:03:43,020
And now we can see our job codes here.

56
00:03:43,190 --> 00:03:48,590
So let's actually click on this activity under line made that example here and double click on the top

57
00:03:48,590 --> 00:03:48,900
here.

58
00:03:48,890 --> 00:03:52,880
So now we should actually design the user interface of our application.

59
00:03:52,910 --> 00:03:56,120
So first of all let's actually delete this whole over text view here.

60
00:03:56,210 --> 00:03:59,180
So just select it and then person delete key on your keyboard.

61
00:03:59,450 --> 00:04:02,310
And now let's actually open the browser.

62
00:04:02,390 --> 00:04:06,320
So here let me actually just refresh this page.

63
00:04:06,320 --> 00:04:13,550
So just click on this refresh button here at the top reload this page and now it's going to show us

64
00:04:13,550 --> 00:04:15,770
the project that we created here.

65
00:04:15,980 --> 00:04:18,750
And we actually connected our application to this to this project.

66
00:04:18,860 --> 00:04:23,530
As you can see it says about 60 free retrieving data from firebase.

67
00:04:23,630 --> 00:04:27,750
So as you can see here we can't actually see the letters here.

68
00:04:28,040 --> 00:04:35,030
So this could be for example maybe it has some limitations regarding the name of the project.

69
00:04:35,030 --> 00:04:42,720
So let's just click on it and now as you can see here the project you can see the panels here.

70
00:04:43,070 --> 00:04:46,850
And let's actually click on this database here.

71
00:04:46,880 --> 00:04:51,900
The database panel just click on it and then just click on the rules tab here.

72
00:04:54,330 --> 00:04:59,940
And we should wait a little bit here in order to see the rules and here as I told you earlier we should

73
00:04:59,940 --> 00:05:06,240
actually make these are just exclamation marks equal operator to equal equal operator so that other

74
00:05:06,240 --> 00:05:12,420
users that are not authenticated to this application can be I can actually use this database and then

75
00:05:12,480 --> 00:05:16,840
we can publish and now it says rules published.

76
00:05:16,860 --> 00:05:17,330
Right.

77
00:05:17,490 --> 00:05:22,980
So now let's actually go back to our data type here specifically can this data tap and now we can actually

78
00:05:22,980 --> 00:05:25,390
interact with this database.

79
00:05:25,410 --> 00:05:35,400
So first of all let's actually go back into our Android studio and now let's design the I actually use

80
00:05:35,400 --> 00:05:37,870
an interface our application.

81
00:05:38,010 --> 00:05:43,930
So here let's actually drag our linearly out vertical into this relatively out here.

82
00:05:43,950 --> 00:05:49,470
So here inside this pallet section is actually just scroll down here as you can see we have these layouts

83
00:05:49,470 --> 00:05:50,260
folder.

84
00:05:50,490 --> 00:05:57,000
So now just select is linear linearly at vertical here and distracted here and put it at the center

85
00:05:57,270 --> 00:06:05,220
of this relatively out here and now let's actually drag an edit text into this linearly at vertical

86
00:06:05,220 --> 00:06:11,820
so inside this takes fields folder just select this plain text here and write it here and put it inside

87
00:06:11,820 --> 00:06:17,080
this linearly as vertical and now as you can see the idea is Eadie text.

88
00:06:17,100 --> 00:06:26,560
So let's actually delete this ID and change it to eat it he she EDT key and then press on until key

89
00:06:26,560 --> 00:06:27,520
on your keyboard.

90
00:06:27,940 --> 00:06:34,750
And unless I actually delete this takes the value of this text and then just present delete key on your

91
00:06:34,750 --> 00:06:37,750
keyboard and they hitch it just for the hint.

92
00:06:37,760 --> 00:06:39,400
Attributes just like in here.

93
00:06:39,760 --> 00:06:42,650
Dot dot dot and then press on Enter key on your keyboard.

94
00:06:44,640 --> 00:06:47,140
And here just select the state's view here.

95
00:06:47,400 --> 00:06:54,790
And for the ID just type in here th the value and then present Enter key on your keyboard and then lets

96
00:06:54,870 --> 00:06:55,500
actually did it.

97
00:06:55,500 --> 00:06:59,340
This takes you here for the text attribute.

98
00:06:59,370 --> 00:07:04,920
And now let's actually write another Potten into this linearly at vertical so in inside these widgets

99
00:07:04,940 --> 00:07:05,580
father.

100
00:07:05,790 --> 00:07:11,010
Just select this button here and put it here inside this linearly at vertical and below.

101
00:07:11,010 --> 00:07:20,860
This takes you here and for for the ID to step in here between and get data from server.

102
00:07:21,830 --> 00:07:32,800
And for the text just typing here gets data from server and then person until 3 on your keyboard.

103
00:07:32,800 --> 00:07:40,630
So now let's actually go inside our main activity the java file here and here inside these uncreate

104
00:07:40,630 --> 00:07:47,680
Smurfette Let's actually just create some objects that actually to be fair to the user interface objects

105
00:07:47,680 --> 00:07:49,780
that we have inside the user interface.

106
00:07:49,900 --> 00:07:50,410
Right.

107
00:07:50,560 --> 00:07:53,970
So now let's go back to our main activity that java file here.

108
00:07:54,370 --> 00:07:57,880
And now let's create these objects here.

109
00:07:57,880 --> 00:08:03,940
So the first object is going to be an edit text suggests they've been here edit text and the name is

110
00:08:03,940 --> 00:08:09,550
going to be EDT key assignment operator and an entity which has this object to an edit takes object

111
00:08:09,880 --> 00:08:17,580
find view by ID or that Id dot EDT Keat and then put a semicolon at the end of your statement.

112
00:08:17,680 --> 00:08:20,670
And now let's actually create another edit edit subject.

113
00:08:20,680 --> 00:08:21,640
EDT.

114
00:08:21,820 --> 00:08:23,920
Value assignment operator.

115
00:08:23,950 --> 00:08:31,900
And then this actually has this object and it takes object find view by ID or that Id dot EDT value

116
00:08:32,200 --> 00:08:34,840
and then put a semicolon at the end of your statement.

117
00:08:35,140 --> 00:08:39,080
And now we need to actually create an object of like button.

118
00:08:39,090 --> 00:08:47,870
So Potten PETN a send data to server assignment operator.

119
00:08:48,010 --> 00:08:53,470
And here I just need to cast this object to an editor to and actually Potten up to about an object so

120
00:08:53,470 --> 00:09:02,650
putten find view by ID or that ID that PTEN as send data to set right and then put a semicolon at the

121
00:09:02,650 --> 00:09:03,800
end of your statement.

122
00:09:04,330 --> 00:09:13,140
And let's actually create a takes few objects takes beauty XTi value assignment operator and then let's

123
00:09:13,140 --> 00:09:21,970
actually cast this object to our Takes objects so takes you find the way Id are that Id thought X the

124
00:09:22,180 --> 00:09:29,040
value and then put a semicolon at the end of your statement and define on a variable that we should

125
00:09:29,050 --> 00:09:29,970
create here.

126
00:09:30,040 --> 00:09:43,650
That can actually hold a value of type but it is actually in PTA and get data from setter and then put

127
00:09:43,650 --> 00:09:49,500
a semicolon here and then put an assignment operator here and here let's actually cast this object to

128
00:09:49,500 --> 00:09:58,980
a button object find view by ID or that ID that PTEN gets data from set and then put a semicolon at

129
00:09:58,980 --> 00:10:00,300
the end of your statement.

130
00:10:01,690 --> 00:10:07,120
And now let's actually create a firebase database here.

131
00:10:07,210 --> 00:10:07,650
So.

132
00:10:07,750 --> 00:10:14,510
So just type in here firebase database and the name is going to be firebase database assignment operator.

133
00:10:14,770 --> 00:10:20,440
And just again referred to the name of this firebase database that get instance if it here as you can

134
00:10:20,440 --> 00:10:26,800
see Firebrace database that get instance in this method get instead this is going to return an instance

135
00:10:26,830 --> 00:10:28,000
of the database.

136
00:10:28,000 --> 00:10:32,650
So now if I show you the web browser browsers you can see here we have this instance of the database

137
00:10:32,650 --> 00:10:33,650
here.

138
00:10:33,670 --> 00:10:41,440
So in this way we can actually get this instance and now that we have access to this firebase database

139
00:10:41,530 --> 00:10:45,370
instance it's actually a reference to our firebase.

140
00:10:45,370 --> 00:10:46,060
Right.

141
00:10:46,060 --> 00:10:49,700
So here I can see database reference.

142
00:10:49,720 --> 00:10:55,030
So as you can see here now we can actually get a reference to the database inside the Firebrace right.

143
00:10:55,030 --> 00:10:59,790
So databases are friends and the name is going to be database reference assignment operator.

144
00:11:00,220 --> 00:11:05,410
And here I can defer to the name of this firebase database instance.

145
00:11:05,410 --> 00:11:12,630
So firebase database instance that get reference or I can see you get a reference from you model or

146
00:11:12,700 --> 00:11:14,830
I can say Get reference here.

147
00:11:14,830 --> 00:11:22,260
So are here I choose this one get reference here or I may want to choose good reference from you at

148
00:11:22,400 --> 00:11:27,910
all or maybe this one gets reference and then put a semicolon at the end of your statement.

149
00:11:27,910 --> 00:11:34,120
This gets reference Smurfette here is going to return to the instance of the firebase that we have here.

150
00:11:34,120 --> 00:11:34,600
Right.

151
00:11:34,780 --> 00:11:41,780
So he's going to give us this actually this instance and now I can actually just write some data to

152
00:11:41,800 --> 00:11:49,520
the database by writing for example a database reference dot and here I can actually create a child

153
00:11:49,850 --> 00:11:54,730
for this instance or I can directly set a value to this instance.

154
00:11:54,740 --> 00:11:57,730
So this actually just test this one set value.

155
00:11:57,920 --> 00:12:04,880
And here I can say some value and then I put a semicolon at the end of my statement.

156
00:12:04,900 --> 00:12:07,710
So now let's run our project.

157
00:12:07,940 --> 00:12:14,660
And now let me show you the web browser and let me show you the Android emulator here.

158
00:12:14,790 --> 00:12:21,140
As you can see now we have access to this of instance to the instance of our database.

159
00:12:21,180 --> 00:12:26,840
And as you can see here we provided a value to this for this instance some value right.

160
00:12:27,120 --> 00:12:32,530
So let's actually just delete this line of code here.

161
00:12:32,550 --> 00:12:37,860
Now let me actually go to the browser and here just click on this delete button here and then press

162
00:12:37,860 --> 00:12:39,370
person delete key on your keyboard.

163
00:12:39,420 --> 00:12:42,960
So Nancy as you can see here the value is not right.

164
00:12:43,260 --> 00:12:52,290
So let's go back to android studio and now I can say for example database reference dot child for example

165
00:12:52,300 --> 00:12:54,500
the child could be a child.

166
00:12:54,660 --> 00:12:57,690
And here I can say that said value.

167
00:12:58,170 --> 00:13:03,720
And here I can assign some value here for example value and then put a semicolon at the end of your

168
00:13:03,720 --> 00:13:04,610
statement.

169
00:13:04,620 --> 00:13:06,920
So now let's run our project and not now.

170
00:13:06,930 --> 00:13:09,040
Let me show you the web browser here.

171
00:13:10,160 --> 00:13:17,340
As you can see here now this database instance has a child and of value right.

172
00:13:17,570 --> 00:13:19,190
So hopefully that makes sense.

173
00:13:19,190 --> 00:13:20,810
So let's go back to android studio.

