1
00:00:00,190 --> 00:00:03,360
An application share preferences.

2
00:00:03,450 --> 00:00:05,620
So an insight is uncreate method.

3
00:00:05,680 --> 00:00:13,270
We need to actually initialize these typeface objects phone number one phone number two and number three.

4
00:00:13,500 --> 00:00:15,150
So inside is uncreate me.

5
00:00:15,180 --> 00:00:19,920
I'm going to actually paste in some lines of code and then I'm going to explain to you what's going

6
00:00:19,920 --> 00:00:20,750
on here.

7
00:00:20,760 --> 00:00:25,680
So as you can see here these are the lines of code that I actually pasted here.

8
00:00:25,740 --> 00:00:32,340
As you can see in line 47 I actually referred to the name of this type phrase object that I actually

9
00:00:32,340 --> 00:00:35,540
declared in line to anyone inside our main activity class.

10
00:00:35,550 --> 00:00:41,380
As you can see here inside our uncreate Meffert I want to actually instantiate this phone number of

11
00:00:41,380 --> 00:00:43,740
an object assignment operator.

12
00:00:43,830 --> 00:00:48,530
So I refer to the name of this class typeface that create from asset.

13
00:00:48,720 --> 00:00:52,410
So first we need to actually access the assets folder in our project.

14
00:00:52,530 --> 00:00:57,860
So in our projects project structure I have these assets folder here.

15
00:00:58,110 --> 00:01:01,990
So this good assets actually allow us to access this folder.

16
00:01:02,400 --> 00:01:06,370
And for the second argument we need to specify the path to our front.

17
00:01:06,480 --> 00:01:10,160
So inside these assets for that I have this Fornes directory.

18
00:01:10,170 --> 00:01:11,680
So Faunce slash.

19
00:01:11,910 --> 00:01:18,040
And this is going to be the name of the format that we want to use chunk 5 that ATF as you can see here.

20
00:01:18,660 --> 00:01:25,860
And again I am actually instantiating this form to number two object assignment operator typeface that

21
00:01:25,860 --> 00:01:32,590
creates from set get assets Faunce as you can see here Faunce Fauntleroy Brown that PTF.

22
00:01:32,640 --> 00:01:38,310
So here as you can see I am instantiating this form to number two object again typeface that create

23
00:01:38,310 --> 00:01:47,400
from aset get assets and here as you can see Fornes slash Fauntleroy Brown that CTF and inline 14:9

24
00:01:47,700 --> 00:01:51,860
again as you can see I am instantiating this phone number of the object.

25
00:01:51,870 --> 00:01:58,560
Assignment operator typeface that creates from assett get assets and here as you can see in say to double

26
00:01:58,560 --> 00:02:06,180
quotes for the second argument I am actually giving the path of the front Faunce slash wunderbar space

27
00:02:06,180 --> 00:02:07,720
them all that Auty at.

28
00:02:08,070 --> 00:02:15,360
So now that I actually specified the the my forms and I actually instantiated my phone's objects.

29
00:02:15,420 --> 00:02:20,020
Now I want to actually override the Andrys your method.

30
00:02:20,370 --> 00:02:27,290
So unless you have it in my main activity class Ok so I can just type on resume and the autocomplete

31
00:02:27,300 --> 00:02:33,600
feature of the Android studio is going to help me to actually select the Smurfit and then press on Enter

32
00:02:33,600 --> 00:02:35,090
key on my keyboard.

33
00:02:35,100 --> 00:02:41,730
So now as you can see I actually overwrite the Smurfit so now and they don't actually work on this on

34
00:02:41,730 --> 00:02:43,000
a resume if it later.

35
00:02:43,150 --> 00:02:48,570
OK in this tutorial but for now let's actually go back again inside this uncreate method and this time

36
00:02:48,660 --> 00:02:52,180
I want to instantiate these shared preferences object.

37
00:02:52,210 --> 00:02:52,720
OK.

38
00:02:52,920 --> 00:02:56,960
So inside this uncreate method I'm going to actually pasting this line of code here.

39
00:02:57,030 --> 00:03:01,140
So as you can see here this is the line of code that I actually paste that here.

40
00:03:01,140 --> 00:03:06,720
And first of all I've referred to the name of this object that I declared in my main activity class

41
00:03:07,100 --> 00:03:09,180
inline 32 as you can see here.

42
00:03:09,180 --> 00:03:16,610
So now inside these uncreate Meffert I am instantiating this object shared preferences assignment operator.

43
00:03:16,740 --> 00:03:23,130
So I've referred to the name of this preference manager class that get shared preferences.

44
00:03:23,340 --> 00:03:30,120
So this object is going to help me and help me to actually save some data inside the shirt.

45
00:03:30,140 --> 00:03:35,200
Proofer and says And whenever I actually I need them I can actually retrieve those data.

46
00:03:35,250 --> 00:03:42,030
So preference managers that create a default shared preferences and in say the practices of this Meffert

47
00:03:42,030 --> 00:03:44,160
we need to actually specify the context.

48
00:03:44,160 --> 00:03:46,960
So the context is going to be the main activity that is.

49
00:03:47,070 --> 00:03:53,160
So now I successfully instantiated these shared preferences object.

50
00:03:53,190 --> 00:03:56,920
So remember let me explain again these shared preferences.

51
00:03:56,940 --> 00:04:02,680
Object is going to help me to save and retrieve data in my application server.

52
00:04:02,760 --> 00:04:09,710
For example when the user changes the format or for example when the user increases the size of a takes

53
00:04:09,710 --> 00:04:16,830
few of you can actually save those information inside the shirt preferences and we can actually retrieve

54
00:04:16,830 --> 00:04:19,640
those information and use it for example closes.

55
00:04:19,760 --> 00:04:22,020
It closes the application and and later.

56
00:04:22,020 --> 00:04:24,030
For example the use that often is the application.

57
00:04:24,150 --> 00:04:30,000
And we can actually retrieve those saved data that are inside these shared preferences so we can actually

58
00:04:30,000 --> 00:04:35,770
use this object in order to save and retrieve data in our application.

59
00:04:36,090 --> 00:04:43,470
So now inside our main activity class I'm actually pasting some lines of code here and then I'm going

60
00:04:43,470 --> 00:04:45,890
to explain to you what's going on here.

61
00:04:45,960 --> 00:04:47,760
So here I'm going to paste in a method.

62
00:04:47,820 --> 00:04:52,830
So as you can see here these are the lines of code that I actually pasted here.

63
00:04:52,830 --> 00:04:54,270
This is actually a method.

64
00:04:54,570 --> 00:04:59,810
And as you can see here in lines 69 flew 94.

65
00:04:59,920 --> 00:05:00,900
Actually MF it.

66
00:05:00,950 --> 00:05:01,430
OK.

67
00:05:01,570 --> 00:05:03,770
So I'm going to explain to you what's going on here.

68
00:05:03,910 --> 00:05:09,970
So as you can see here first about the access modifier of my method inside the main activity class is

69
00:05:09,970 --> 00:05:13,280
actually Puplick the return type is void.

70
00:05:13,360 --> 00:05:16,350
So this is going to actually return nothing.

71
00:05:16,660 --> 00:05:21,250
And the name of this effort is specifically the font for text you want.

72
00:05:21,460 --> 00:05:28,090
OK so the purpose of this if it is is to actually specify what kinds of fonts you want to actually use

73
00:05:28,270 --> 00:05:29,800
for our text view one.

74
00:05:29,800 --> 00:05:30,360
OK.

75
00:05:30,400 --> 00:05:36,170
Well we actually select a font and and if it is going to actually do its job for us.

76
00:05:36,340 --> 00:05:39,190
OK so let's see what are the lines of code.

77
00:05:39,190 --> 00:05:41,770
What is the logic inside this effort.

78
00:05:41,860 --> 00:05:48,640
So first of all as you can see I created this bully invaluable and as you can see here the name of this

79
00:05:48,640 --> 00:05:55,720
boolean boolean value but is Phone number one for text view for text that takes one value as you can

80
00:05:55,720 --> 00:05:56,480
see here.

81
00:05:56,560 --> 00:06:03,850
This is actually a boolean value variable and as it as you mean no Boolean value it can only hold true

82
00:06:03,910 --> 00:06:05,120
or false values.

83
00:06:05,140 --> 00:06:09,270
Ok so the name of this variable is false.

84
00:06:09,310 --> 00:06:11,540
Number one for takes one value.

85
00:06:11,650 --> 00:06:12,240
OK.

86
00:06:12,520 --> 00:06:18,310
And we have another boolean valuable and the name of this variable is false.

87
00:06:18,310 --> 00:06:20,860
Number 2 for text 1 value.

88
00:06:21,080 --> 00:06:22,010
OK.

89
00:06:22,210 --> 00:06:26,880
And we have another really invaluable phone number free for text 1 value.

90
00:06:26,950 --> 00:06:27,480
OK.

91
00:06:27,760 --> 00:06:30,300
So inside is some of it as you can see here.

92
00:06:30,340 --> 00:06:35,680
I am actually instantiating this these bullion valuables that I created here.

93
00:06:35,680 --> 00:06:41,440
So again I'll fair to the name of this phone number one for text one value here.

94
00:06:41,440 --> 00:06:48,460
Assignment operator so shared preferences as you can see here we have these shared preferences.

95
00:06:48,460 --> 00:06:51,600
So remember in our emulator Let me show you.

96
00:06:51,610 --> 00:06:57,350
So let's actually do on our project now and in our emulator I want us actually to show you something

97
00:06:57,350 --> 00:06:57,990
in here.

98
00:06:58,120 --> 00:07:01,740
So now as you can see our application is running on this emulator here.

99
00:07:01,740 --> 00:07:02,320
Right.

100
00:07:02,350 --> 00:07:06,250
So if I click on this I mean your button here and click on these settings here.

101
00:07:06,280 --> 00:07:08,510
Now as you can see this is the settings.

102
00:07:08,740 --> 00:07:13,720
This is the this is actually a preference category for our ticket number one sitting right.

103
00:07:13,740 --> 00:07:15,950
So here as you can see I have free phones.

104
00:07:16,120 --> 00:07:22,480
So if we actually select this phone here and uncheck this phone here I want to actually for example

105
00:07:22,870 --> 00:07:27,500
choose this format for my text Vonte value for my text you want.

106
00:07:27,550 --> 00:07:33,820
So as you can see here if I actually as you can see if I select this checkbox the value of this checkbox

107
00:07:33,880 --> 00:07:35,850
is TLOU is true right.

108
00:07:36,250 --> 00:07:41,640
And if I unchecked this checkbox now the value of this checkbox is false.

109
00:07:41,950 --> 00:07:44,900
Ok this is very important when it's actually checked.

110
00:07:45,010 --> 00:07:45,850
It is true.

111
00:07:46,000 --> 00:07:48,790
And when it's unchecked it is false.

112
00:07:48,790 --> 00:07:54,370
So if you actually check this checkbox and actually come back you've in here that effect it must actually

113
00:07:54,370 --> 00:07:56,520
happen here or the text you want.

114
00:07:56,530 --> 00:07:58,080
This is text number 1 right.

115
00:07:58,330 --> 00:08:05,110
So here as you can see I have these boolean value Burleigh's here that's actually going to hold.

116
00:08:05,110 --> 00:08:06,820
Those are true or false values.

117
00:08:06,820 --> 00:08:13,800
For example when the user checks the phone number one of you all for example is foreign.

118
00:08:14,140 --> 00:08:15,160
So remember this is false.

119
00:08:15,160 --> 00:08:17,750
Number one this is phone number two this is phone number free.

120
00:08:17,770 --> 00:08:18,640
Right.

121
00:08:18,640 --> 00:08:19,560
As you can see here.

122
00:08:19,570 --> 00:08:27,670
So for example if to use a check this checkbox that is Phone number one as you can see here that's valuable

123
00:08:27,670 --> 00:08:28,160
here.

124
00:08:28,160 --> 00:08:32,740
Phone number one for text one value here as you can see this is anti-bully right.

125
00:08:32,750 --> 00:08:38,490
That's that value that's valuable is going to actually hold true value.

126
00:08:38,890 --> 00:08:40,300
OK this is really important.

127
00:08:40,360 --> 00:08:47,440
Or if they use it for example or checks this checkbox and unchecked this checkbox here it is a second

128
00:08:47,440 --> 00:08:50,780
variable here is going to actually hold true valuable.

129
00:08:50,920 --> 00:08:54,040
And this first one is going to hold a false value.

130
00:08:54,040 --> 00:08:57,880
This second valuable is going to hold a true value.

131
00:08:57,880 --> 00:09:00,270
The first one is going to hold as you can see here.

132
00:09:00,280 --> 00:09:03,850
This first one which is checked is going to hold a false value.

133
00:09:03,850 --> 00:09:04,830
Right.

134
00:09:04,840 --> 00:09:06,700
So let's see what what we are doing here.

135
00:09:06,700 --> 00:09:12,230
So front number of on four takes one value assignment operator shared preferences.

136
00:09:12,230 --> 00:09:19,620
So this is the share of preferences for actually accessing it and actually saving the data in our application.

137
00:09:19,810 --> 00:09:23,610
So this is really important shared answers that get Polyana.

138
00:09:23,610 --> 00:09:29,640
So here we want to get the boolean value OK checkbox Faunce number one text 1.

139
00:09:29,650 --> 00:09:30,940
So this is the key.

140
00:09:31,090 --> 00:09:38,050
So this key is actually inside these preferences underlined find that XML here I specify this key here

141
00:09:38,290 --> 00:09:39,420
for this.

142
00:09:39,760 --> 00:09:45,250
For example for this front here that is related to this text number one settings inside this preference

143
00:09:45,250 --> 00:09:47,890
category of this takes number 1 settings.

144
00:09:47,890 --> 00:09:54,820
This is that she checks checkbox format number of one text one as you can see here.

145
00:09:54,850 --> 00:09:57,720
So this is the kid in order to access this.

146
00:09:58,210 --> 00:10:03,810
Actually this checkbox it's OK in order to access the value of this tick box preference.

147
00:10:03,820 --> 00:10:05,670
So he said this an activity that I will find here.

148
00:10:05,710 --> 00:10:10,650
I am actually getting the boolean value if the user checks text that checkbox here.

149
00:10:10,680 --> 00:10:16,290
As you can see if I unchecked this checkbox and if the user checks this checkbox here that is for another

150
00:10:16,300 --> 00:10:18,050
one event.

151
00:10:18,130 --> 00:10:22,930
When we call these shared preferences that get bullion is going to actually return our true value as

152
00:10:22,930 --> 00:10:24,820
you can see here.

153
00:10:25,020 --> 00:10:29,440
It's going to return this true value because I checked this checkbox.

154
00:10:29,550 --> 00:10:33,120
So here as you can see pretty answers that get bullion.

155
00:10:33,120 --> 00:10:33,970
This is the key.

156
00:10:34,140 --> 00:10:35,880
And here I have this false value.

157
00:10:35,880 --> 00:10:37,900
This is actually a default value.

158
00:10:38,010 --> 00:10:41,280
If the application fails to access the share preferences.

159
00:10:41,430 --> 00:10:43,010
So this is not going to happen.

160
00:10:43,020 --> 00:10:46,570
But if that happens it's going to actually assign the value falls.

161
00:10:46,740 --> 00:10:50,970
But don't worry about this always it's going to actually give you the right value.

162
00:10:51,080 --> 00:10:56,560
And here as you can see I have this phone number two for text 1 value.

163
00:10:56,670 --> 00:10:59,290
So as you can see here this is number one sitting right.

164
00:10:59,340 --> 00:11:04,900
We are inside this as you can see inside these preferences Underland Follet find that example here of

165
00:11:04,900 --> 00:11:08,730
your insight this category preprinted skeptically that is for these takes.

166
00:11:08,730 --> 00:11:09,930
Number one settings.

167
00:11:10,080 --> 00:11:16,650
And here I want to access this checkbox the second checkbox that holds this fall Fauntleroy down here

168
00:11:16,680 --> 00:11:17,910
as you can see.

169
00:11:17,910 --> 00:11:23,400
So in this minute if the date of a file here I'll refer to the name of this valuable phone number two

170
00:11:23,400 --> 00:11:26,670
for text 1 value assignment operator.

171
00:11:26,670 --> 00:11:28,970
So here I want to get this boolean value.

172
00:11:29,040 --> 00:11:36,300
So in my emulator here if they use that uncheck this checkbox and checks this checkbox here the value

173
00:11:36,300 --> 00:11:38,320
of the check box is true now right.

174
00:11:38,400 --> 00:11:40,740
Shall share preferences that get bullion.

175
00:11:40,800 --> 00:11:46,650
Now I actually fell to this to this key here that I actually put inside this pretty Francis underlined

176
00:11:46,650 --> 00:11:47,750
file that example here.

177
00:11:47,760 --> 00:11:50,120
As you can see this is that key.

178
00:11:50,610 --> 00:11:55,980
And inside this main activity of a fight here I used that key in order to access its value in order

179
00:11:55,980 --> 00:11:57,140
to access this.

180
00:11:57,270 --> 00:12:04,740
True or false value if the user takes this checkbox the value of this checkbox is now true if the user

181
00:12:04,830 --> 00:12:09,180
undertakes this checkbox the value of this checkbox is false.

182
00:12:09,180 --> 00:12:09,700
OK.

183
00:12:09,930 --> 00:12:11,120
And it's going to get that value.

184
00:12:11,130 --> 00:12:13,370
And here is the default value.

185
00:12:13,770 --> 00:12:21,360
And here I have this phone number free for text 1 value assignment operator shared preferences that

186
00:12:21,360 --> 00:12:22,300
get boolean.

187
00:12:22,500 --> 00:12:26,660
Again as you can see we have this key for the first form.

188
00:12:26,700 --> 00:12:32,220
So in say disproove Francis underlined files that examine as you can see here you are accessing this

189
00:12:32,370 --> 00:12:36,530
checkbox here of this take box preference for the form.

190
00:12:36,570 --> 00:12:39,090
As you can see this is the number of free.

191
00:12:39,300 --> 00:12:42,860
And in say this me an activity that I will find here we want to access that form.

192
00:12:42,870 --> 00:12:49,030
So here in our emulator if the user checks this checkbox this is the number of free write this checkbox

193
00:12:49,040 --> 00:12:51,140
is going to actually hold the value true.

194
00:12:51,270 --> 00:12:58,080
And if the user unchecked this checkbox this checkbox is going to actually hold the value for its social

195
00:12:58,080 --> 00:13:00,770
preferences that get bullied and this is the key.

196
00:13:01,110 --> 00:13:03,530
And this is the default value.

197
00:13:03,750 --> 00:13:06,340
And here I created some if statements.

198
00:13:06,390 --> 00:13:13,180
So here I am saying that if the value of this phone number on four takes one value this boolean value.

199
00:13:13,200 --> 00:13:19,190
But as you can see here if the value of this phone number one for takes one value is actually true.

200
00:13:19,680 --> 00:13:26,720
It's going to actually set the typeface for this text the number text the text number one here.

201
00:13:26,730 --> 00:13:32,750
So in our emulator here if you click on this back button here as you can see if the user checks the

202
00:13:32,890 --> 00:13:35,090
box at this chunk file format right.

203
00:13:35,100 --> 00:13:36,350
This is for another one.

204
00:13:36,570 --> 00:13:41,690
And here you refer to this valuable if number one for takes one value is true.

205
00:13:41,760 --> 00:13:48,980
So if the user checks this checkbox if I click on dispatch button here that actually that changes is

206
00:13:48,990 --> 00:13:50,090
going to happen.

207
00:13:50,110 --> 00:13:55,210
And this takes you here the front of the stakes you must change to what.

208
00:13:55,260 --> 00:13:56,910
To this vault number one.

209
00:13:57,120 --> 00:14:03,060
So this four to number one I actually hold declare this one to not number one in our main activity class

210
00:14:03,120 --> 00:14:03,960
as you can see.

211
00:14:04,200 --> 00:14:11,420
And inside on our create method inside this uncreate Meffert I instantiated this actually.

212
00:14:11,720 --> 00:14:18,120
I instantiated this for another one here as you can see here typeface that create from asset get assets.

213
00:14:18,120 --> 00:14:24,780
So here as you can see I'll refer to the front Faunce slash chunk 5 that ATF right.

214
00:14:24,840 --> 00:14:26,790
So I have this front here.

215
00:14:27,060 --> 00:14:33,890
And as you can see here in our statement here in inside our Meffert specify the font for text view 1

216
00:14:34,340 --> 00:14:39,800
I created this statement and I am saying that if the value of this phone number of one for takes over

217
00:14:39,930 --> 00:14:45,250
takes one value is true then a set the typeface for this text number one.

218
00:14:45,270 --> 00:14:50,790
This takes you here as you can see set the typeface for this Tillich's the text number of on two fronts.

219
00:14:50,790 --> 00:14:52,580
Number one right.

220
00:14:52,590 --> 00:14:53,540
If this is true.

221
00:14:53,700 --> 00:14:55,790
Set the typeface to front number one.

222
00:14:56,100 --> 00:15:04,790
And I have another as if statement so as if this is if means that it is a valid expression here.

223
00:15:04,920 --> 00:15:06,410
This condition here is false.

224
00:15:06,480 --> 00:15:09,110
And then it's going to check this condition here else.

225
00:15:09,150 --> 00:15:16,980
If the value of this value but the number to four takes one value is actually true then it's going to

226
00:15:16,980 --> 00:15:23,770
actually assign this typeface to the text number to that set typeface for the number two.

227
00:15:23,970 --> 00:15:30,040
And we have other else if so if this condition again fails if this condition here is false then it's

228
00:15:30,040 --> 00:15:36,040
going to check this condition here else if for another fee for takes one value is true then it's going

229
00:15:36,040 --> 00:15:37,570
to execute this line I've got here.

230
00:15:37,570 --> 00:15:40,840
He actually takes a number of that set type face for another free.

231
00:15:41,170 --> 00:15:41,730
OK.

232
00:15:42,010 --> 00:15:46,030
So now let's actually so here is RMF it right.

233
00:15:46,030 --> 00:15:51,110
So now that I have this method this specify the form for takes one method.

234
00:15:51,250 --> 00:15:52,860
Now I need to call the Smurfette.

235
00:15:52,870 --> 00:16:00,320
But in my quote which place is going to be the best place to call this fit inside this is your method

236
00:16:00,340 --> 00:16:05,780
that we actually override that inside our main activity class as you can see here.

237
00:16:05,890 --> 00:16:07,150
This is the resume of it.

238
00:16:07,150 --> 00:16:14,290
So let's actually create a toast here in order to show to the user of this if it is going is going to

239
00:16:14,290 --> 00:16:19,780
be called so toast that takes that make.

240
00:16:19,930 --> 00:16:25,960
First of all we need to pass the context main activity that this comma and here is the text that you

241
00:16:25,960 --> 00:16:27,410
want to show to the user.

242
00:16:27,550 --> 00:16:38,040
And now inside the double quotes I can just typing this on Raise your Meffert this on resume Mefford

243
00:16:39,810 --> 00:16:49,400
is called and then for the first argument we need to specify the duration length short that short.

244
00:16:49,440 --> 00:16:54,150
So we need to call this shawm effort on this object in order to show this to the user.

245
00:16:54,180 --> 00:16:58,210
So let's actually click click on run here and then click on OK.

246
00:16:58,380 --> 00:17:04,050
So now as you can see our application is actually running on the simulator and the on resume effort

247
00:17:04,080 --> 00:17:05,480
is called Right.

248
00:17:05,520 --> 00:17:10,510
So if you actually click on the menu button here and then click on settings and here for example check

249
00:17:10,530 --> 00:17:17,800
this checkbox here as you can see and then click and back again this will resume if it is called Right.

250
00:17:17,850 --> 00:17:24,840
So this is you if it is going to be the best place to call this specify the format for text view you

251
00:17:24,870 --> 00:17:25,370
one it.

252
00:17:25,380 --> 00:17:28,140
OK this is the best place on the resume it.

253
00:17:28,200 --> 00:17:35,190
So if we call this Smurfette here specify the font for text view one.

254
00:17:35,360 --> 00:17:39,460
Now let's actually run our project and see what happens.

