1
00:00:00,370 --> 00:00:07,770
So let's actually create a toast in the and put unpause Mefford so toast that make text and first of

2
00:00:07,770 --> 00:00:12,370
all we need to specify the context main activity that this come up.

3
00:00:12,540 --> 00:00:20,150
And for the second argument we need to specify the text so the text is going to be the excuse me in

4
00:00:20,190 --> 00:00:31,550
inside the double quotes the ON PAUSE Meffert is called unpause must be with lowercase.

5
00:00:31,620 --> 00:00:36,490
Oh and for the first argument we need to specify the length.

6
00:00:36,790 --> 00:00:39,270
So Len for short start show.

7
00:00:39,480 --> 00:00:40,160
OK.

8
00:00:40,540 --> 00:00:42,480
And for this is your Mefford.

9
00:00:42,490 --> 00:00:44,650
Let's actually create again a toast.

10
00:00:44,650 --> 00:00:49,450
So I'm going to actually copy this line of quote here this tossed here and then I'm going to paste it

11
00:00:49,450 --> 00:00:50,040
here.

12
00:00:50,260 --> 00:00:57,700
And for the text I'm going to just type in the and resume Meffert on resume if it is called.

13
00:00:57,790 --> 00:01:01,230
So analysis around our project here again and see what happens.

14
00:01:01,240 --> 00:01:05,800
So now as you can see our application is running and the resume effort is called.

15
00:01:05,800 --> 00:01:06,370
OK.

16
00:01:06,580 --> 00:01:11,750
So now I want to actually click on dispatch button and it says the unpause method is called.

17
00:01:12,010 --> 00:01:19,120
So whenever the on Pazz method is called I want to actually save the state of my checkbox or keep whether

18
00:01:19,120 --> 00:01:25,900
it is checked or or not checked and vent whenever the on resume if it is called or you want to actually

19
00:01:25,900 --> 00:01:27,810
to retrieve it.

20
00:01:27,910 --> 00:01:30,890
That's the it's OK whether it is checked or unchecked.

21
00:01:31,120 --> 00:01:32,380
So how can I do that.

22
00:01:32,500 --> 00:01:34,370
Inside this unpause method.

23
00:01:34,780 --> 00:01:40,510
As you can see here I'm going to paste in some lines of code here inside this unpack Smurfette and then

24
00:01:40,510 --> 00:01:43,000
I'm going to explain to you what's going on here.

25
00:01:43,000 --> 00:01:43,670
OK.

26
00:01:43,810 --> 00:01:47,930
So as you can see here these are the lines of code that I actually pasted.

27
00:01:47,950 --> 00:01:49,860
Instead it is on puzzle method.

28
00:01:49,870 --> 00:01:50,420
OK.

29
00:01:50,590 --> 00:01:57,080
So as you can see here in line 55 First of all I created an object he had of type shared preferences

30
00:01:57,160 --> 00:01:57,940
as you can see.

31
00:01:58,090 --> 00:01:59,860
So this is the shirt preferences class.

32
00:02:00,040 --> 00:02:01,840
And this is the name of the object.

33
00:02:01,850 --> 00:02:02,940
Share preferences.

34
00:02:03,100 --> 00:02:05,960
Assignment operator get preferences.

35
00:02:05,980 --> 00:02:06,550
0.

36
00:02:06,690 --> 00:02:07,120
OK.

37
00:02:07,180 --> 00:02:12,220
So I want to actually get the preferences so I need to actually call the Smurfette get preferences and

38
00:02:12,220 --> 00:02:16,550
I need to pass this number zero to the Smurfit in order to get a preference.

39
00:02:16,630 --> 00:02:21,960
So now I have the preferences in order to save the state of the checkbox OK.

40
00:02:22,060 --> 00:02:25,590
Preferences and inline 56 as you can see.

41
00:02:25,720 --> 00:02:29,470
I call this the name of this class share preferences that editor.

42
00:02:29,620 --> 00:02:35,590
So this time I want to actually create an object of type shirt preferences that editor OK I want to

43
00:02:35,680 --> 00:02:36,030
edit.

44
00:02:36,040 --> 00:02:43,270
I want to actually save some state to the memory so shall prove it says that editor editor assignment

45
00:02:43,270 --> 00:02:44,030
operator.

46
00:02:44,290 --> 00:02:49,290
And here again are you referred to the name of this object shared preferences that it.

47
00:02:49,570 --> 00:02:50,740
So now I have an editor.

48
00:02:50,740 --> 00:02:58,180
OK so now as you can see in 9:57 as you can see here I'll referred to the name of this editor object

49
00:02:58,390 --> 00:03:00,800
editor that put strange.

50
00:03:00,970 --> 00:03:06,620
And as you can see here inside this inside the practices of this Smurfette I have two arguments.

51
00:03:06,730 --> 00:03:10,800
The first one is the key checkbox text value.

52
00:03:10,810 --> 00:03:18,030
So I want to actually see the text of this or checkbox actually open or application again.

53
00:03:18,290 --> 00:03:20,320
50 as you can see here.

54
00:03:20,770 --> 00:03:26,170
Now as you can see when I checked this checkbox I want to actually end up on when the unpause method

55
00:03:26,170 --> 00:03:27,300
is actually called.

56
00:03:27,370 --> 00:03:30,600
I want to save this text to them and will be OK.

57
00:03:30,670 --> 00:03:31,950
The checkbox is checked.

58
00:03:31,990 --> 00:03:33,330
You want to save this text.

59
00:03:33,520 --> 00:03:36,660
So here that's why I actually created this line of code here.

60
00:03:36,670 --> 00:03:38,430
Editor that puts strange.

61
00:03:38,440 --> 00:03:41,780
I want to actually put this string value in the memory.

62
00:03:41,800 --> 00:03:45,600
So the key is going to be checkbox under link takes the underlying value.

63
00:03:45,700 --> 00:03:49,650
So remember that your keys always should be capitalized.

64
00:03:49,720 --> 00:03:51,680
OK inside the double quotes as you can see here.

65
00:03:51,790 --> 00:03:53,860
This is going to be a string value right.

66
00:03:54,010 --> 00:04:00,530
And for the second the argument we are going to actually save the actually the main value OK that the

67
00:04:00,520 --> 00:04:02,820
string value that you want to save to the memory.

68
00:04:02,860 --> 00:04:08,240
This is the key and this is the string by the checkbox that gettext that with string.

69
00:04:08,320 --> 00:04:11,160
So here I am actually getting the text of this checkbox.

70
00:04:11,290 --> 00:04:17,830
And here I am actually put in get into the putting this value inside the memory shared preferences editor

71
00:04:18,100 --> 00:04:23,110
that puts strange checkbox takes three new checkbox that get text to a string.

72
00:04:23,310 --> 00:04:23,730
OK.

73
00:04:23,770 --> 00:04:30,580
So here I am actually saving this state actually the text of this checkbox to the memory and inline

74
00:04:30,710 --> 00:04:36,550
58 as you can see here again I referred to the name of this editor object that put Boullion.

75
00:04:36,580 --> 00:04:42,860
So whenever they use it for example checks this checkbox as you can see now the search box is there

76
00:04:42,860 --> 00:04:43,350
to check it.

77
00:04:43,360 --> 00:04:43,640
OK.

78
00:04:43,660 --> 00:04:46,790
And this means that the value of the tick box is actually true.

79
00:04:46,810 --> 00:04:48,620
So this is a boolean value right.

80
00:04:48,640 --> 00:04:49,540
True or false.

81
00:04:49,600 --> 00:04:55,670
This is true when it's been when it is checked it is true and it is unchecked it is false.

82
00:04:55,840 --> 00:04:59,490
So I want to actually put this bullion value also inside the memory.

83
00:04:59,500 --> 00:05:03,790
I want to save this state so editor that put bullion.

84
00:05:03,840 --> 00:05:09,700
This is going to be the key checkbox value and this is going to be the main value checkbox that is checked.

85
00:05:09,700 --> 00:05:14,920
Here it is going is going to actually get the checked state of this checkbox.

86
00:05:15,070 --> 00:05:20,170
And here in line 59 you need to actually call this method instead of climate in order to save these

87
00:05:20,170 --> 00:05:23,750
values in say the memory the checkbox is checked.

88
00:05:24,130 --> 00:05:26,570
So now if I actually click on this.

89
00:05:26,650 --> 00:05:32,760
In here and the unperson if it is called Now these are actually these lines of code for example are

90
00:05:32,760 --> 00:05:39,180
executed and it's unnaturally safe these values these are the text of the checkbox and the State of

91
00:05:39,180 --> 00:05:42,680
the checkbox whether it is checked or unchecked and it's and it's going to come.

92
00:05:42,680 --> 00:05:44,270
That changes OK.

93
00:05:44,590 --> 00:05:51,630
And unless your afraid for example when the user again open this application and this on a resume if

94
00:05:51,630 --> 00:05:57,510
it is called locate in this life they want to actually to retrieve those information that is saved inside

95
00:05:57,570 --> 00:05:58,940
this unpause method.

96
00:05:59,190 --> 00:06:00,470
So how can I do that.

97
00:06:00,480 --> 00:06:04,230
So here again I'm going to actually paste in some lines of quote and then I'm going to explain to you

98
00:06:04,470 --> 00:06:05,660
what's going on here.

99
00:06:05,670 --> 00:06:10,540
So as you can see here these are the lines of code that I actually pasted here.

100
00:06:10,620 --> 00:06:13,040
So now I'm going to explain to you what's going on here.

101
00:06:13,260 --> 00:06:14,320
In-lens 71.

102
00:06:14,340 --> 00:06:20,680
Again I need to actually access the shared preferences of my application OK shows the preferences inside

103
00:06:20,700 --> 00:06:23,010
the Android to the Android device.

104
00:06:23,010 --> 00:06:25,920
I am actually actually accessing that showed preferences.

105
00:06:26,070 --> 00:06:30,780
And again I am actually calling this Meffert get preferences zero in order to access the shared preferences

106
00:06:30,780 --> 00:06:34,620
of my device an inline 72 as you can see.

107
00:06:34,620 --> 00:06:40,570
I created a boolean value of boolean value a bell and the name of this value but is checkbox value.

108
00:06:40,620 --> 00:06:41,210
OK.

109
00:06:41,580 --> 00:06:43,150
An assignment operator.

110
00:06:43,290 --> 00:06:49,310
So here you want to assign a value to this value but right checkbox value share preferences here.

111
00:06:49,500 --> 00:06:54,190
I am actually filling to the name of this object shared prevented that gets Boullion.

112
00:06:54,210 --> 00:06:56,590
So I want to get a boolean value right.

113
00:06:56,860 --> 00:07:01,800
And here as you can see inside the prentices of the Smurfette I have two arguments the first one is

114
00:07:01,800 --> 00:07:02,550
the key.

115
00:07:02,790 --> 00:07:07,800
As you can see this key is the same as this key that I actually put here in order to save this boolean

116
00:07:07,800 --> 00:07:10,320
value right checkbox value.

117
00:07:10,410 --> 00:07:12,760
And the second one is actually a default value.

118
00:07:12,870 --> 00:07:17,640
So when the application for example fails to access the shift differences.

119
00:07:17,640 --> 00:07:22,690
In some cases it can actually put the false value to this checkbox value.

120
00:07:22,740 --> 00:07:28,760
OK so 99 percent of the time it's going to actually get the value of the checkbox and it's going to

121
00:07:28,770 --> 00:07:30,540
actually keep this piece of code here.

122
00:07:30,540 --> 00:07:31,540
This false value.

123
00:07:31,680 --> 00:07:37,840
But here we need to actually put a default value or a false and in line 73.

124
00:07:37,890 --> 00:07:45,110
If we have this idea of type String checkbox string value and as you can see here assignment operator

125
00:07:45,870 --> 00:07:50,370
again I actually work through the name of this object shared preferences that gets stream.

126
00:07:50,370 --> 00:07:52,120
So you want to get a string value.

127
00:07:52,230 --> 00:07:53,850
Again as you can see we have this CI.

128
00:07:53,880 --> 00:07:55,860
So this is the same as Diski.

129
00:07:56,130 --> 00:07:58,320
In order to get this string value right.

130
00:07:58,440 --> 00:08:00,570
So a check box takes the value.

131
00:08:00,570 --> 00:08:03,490
And this is going to be strange a default value.

132
00:08:03,620 --> 00:08:09,030
So when the application fails to access the show preferences in order to access these values is going

133
00:08:09,200 --> 00:08:11,880
to assign this value to the text of the checkbox.

134
00:08:11,880 --> 00:08:15,210
This is my check works right and in line 74.

135
00:08:15,210 --> 00:08:20,820
Again I referred to the name of this checkbox object here as you can see in our main activity class

136
00:08:21,120 --> 00:08:24,540
I referred to the name of the checkbox object that said check it.

137
00:08:24,540 --> 00:08:29,230
So I want to actually specify the state of my checkbox.

138
00:08:29,340 --> 00:08:35,910
I want to actually determine whether it is going to be checked or not checked checkbox that said checked

139
00:08:36,150 --> 00:08:42,530
checkbox value as you can see here checkbox that said text checkbox string value as you can see here

140
00:08:42,550 --> 00:08:44,450
I have this thing value here.

141
00:08:44,490 --> 00:08:47,340
So it's going to assign these values to these checkbox here.

142
00:08:47,490 --> 00:08:50,340
So now let's run our project and see what happens.

143
00:08:50,400 --> 00:08:55,080
So now as you can see our application is running on this emulator here.

144
00:08:55,080 --> 00:08:57,900
So now I want to actually check this checkbox.

145
00:08:58,050 --> 00:09:03,570
So now as you can see this box is actually checked and the text of the search box is the checkbox is

146
00:09:03,570 --> 00:09:04,160
checked.

147
00:09:04,290 --> 00:09:07,780
OK so now I want to actually click on this back button here.

148
00:09:07,800 --> 00:09:12,810
So now the application is actually destroyed from their memory and the unpause Moffit is actually called.

149
00:09:13,140 --> 00:09:16,670
And again I want to open this application up for 50.

150
00:09:16,980 --> 00:09:19,540
And as you can see here this state is actually changed.

151
00:09:19,770 --> 00:09:20,040
OK.

152
00:09:20,040 --> 00:09:25,140
And the resume if it is called and we can and we actually retrieved the information the checkbox is

153
00:09:25,140 --> 00:09:29,520
checked and we can see that the actual checkbox is actually checked.

154
00:09:29,700 --> 00:09:30,670
OK.

155
00:09:31,140 --> 00:09:33,800
And now it's actually unticketed checkbox.

156
00:09:33,870 --> 00:09:40,260
And as you can see this text here Solas again click on this batch button here and it's actually up for

157
00:09:40,260 --> 00:09:43,050
example close this application in the background.

158
00:09:43,050 --> 00:09:46,980
And again I want to actually open this application at 50.

159
00:09:47,400 --> 00:09:49,650
And as you can see here this state is changed.

160
00:09:49,800 --> 00:09:51,340
The checkbox is not checked.

161
00:09:51,390 --> 00:09:54,440
And as you can see it is on checked right.

162
00:09:54,870 --> 00:09:56,540
So hopefully that makes sense.

163
00:09:56,580 --> 00:09:59,610
And I think that's enough for this tutorial.

164
00:09:59,610 --> 00:10:04,950
So if you have any questions please post the discussion in the course and then I'll do my best to answer

165
00:10:05,010 --> 00:10:05,900
all of your questions.

166
00:10:05,910 --> 00:10:09,770
Thank you very much for watching and I'll see you in the next tutorial.

