So let's actually create a toast in the and put unpause Mefford so toast that make text and first of
all we need to specify the context main activity that this come up.
And for the second argument we need to specify the text so the text is going to be the excuse me in
inside the double quotes the ON PAUSE Meffert is called unpause must be with lowercase.
Oh and for the first argument we need to specify the length.
So Len for short start show.
OK.
And for this is your Mefford.
Let's actually create again a toast.
So I'm going to actually copy this line of quote here this tossed here and then I'm going to paste it
here.
And for the text I'm going to just type in the and resume Meffert on resume if it is called.
So analysis around our project here again and see what happens.
So now as you can see our application is running and the resume effort is called.
OK.
So now I want to actually click on dispatch button and it says the unpause method is called.
So whenever the on Pazz method is called I want to actually save the state of my checkbox or keep whether
it is checked or or not checked and vent whenever the on resume if it is called or you want to actually
to retrieve it.
That's the it's OK whether it is checked or unchecked.
So how can I do that.
Inside this unpause method.
As you can see here I'm going to paste in some lines of code here inside this unpack Smurfette and then
I'm going to explain to you what's going on here.
OK.
So as you can see here these are the lines of code that I actually pasted.
Instead it is on puzzle method.
OK.
So as you can see here in line 55 First of all I created an object he had of type shared preferences
as you can see.
So this is the shirt preferences class.
And this is the name of the object.
Share preferences.
Assignment operator get preferences.
0.
OK.
So I want to actually get the preferences so I need to actually call the Smurfette get preferences and
I need to pass this number zero to the Smurfit in order to get a preference.
So now I have the preferences in order to save the state of the checkbox OK.
Preferences and inline 56 as you can see.
I call this the name of this class share preferences that editor.
So this time I want to actually create an object of type shirt preferences that editor OK I want to
edit.
I want to actually save some state to the memory so shall prove it says that editor editor assignment
operator.
And here again are you referred to the name of this object shared preferences that it.
So now I have an editor.
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
editor that put strange.
And as you can see here inside this inside the practices of this Smurfette I have two arguments.
The first one is the key checkbox text value.
So I want to actually see the text of this or checkbox actually open or application again.
50 as you can see here.
Now as you can see when I checked this checkbox I want to actually end up on when the unpause method
is actually called.
I want to save this text to them and will be OK.
The checkbox is checked.
You want to save this text.
So here that's why I actually created this line of code here.
Editor that puts strange.
I want to actually put this string value in the memory.
So the key is going to be checkbox under link takes the underlying value.
So remember that your keys always should be capitalized.
OK inside the double quotes as you can see here.
This is going to be a string value right.
And for the second the argument we are going to actually save the actually the main value OK that the
string value that you want to save to the memory.
This is the key and this is the string by the checkbox that gettext that with string.
So here I am actually getting the text of this checkbox.
And here I am actually put in get into the putting this value inside the memory shared preferences editor
that puts strange checkbox takes three new checkbox that get text to a string.
OK.
So here I am actually saving this state actually the text of this checkbox to the memory and inline
58 as you can see here again I referred to the name of this editor object that put Boullion.
So whenever they use it for example checks this checkbox as you can see now the search box is there
to check it.
OK.
And this means that the value of the tick box is actually true.
So this is a boolean value right.
True or false.
This is true when it's been when it is checked it is true and it is unchecked it is false.
So I want to actually put this bullion value also inside the memory.
I want to save this state so editor that put bullion.
This is going to be the key checkbox value and this is going to be the main value checkbox that is checked.
Here it is going is going to actually get the checked state of this checkbox.
And here in line 59 you need to actually call this method instead of climate in order to save these
values in say the memory the checkbox is checked.
So now if I actually click on this.
In here and the unperson if it is called Now these are actually these lines of code for example are
executed and it's unnaturally safe these values these are the text of the checkbox and the State of
the checkbox whether it is checked or unchecked and it's and it's going to come.
That changes OK.
And unless your afraid for example when the user again open this application and this on a resume if
it is called locate in this life they want to actually to retrieve those information that is saved inside
this unpause method.
So how can I do that.
So here again I'm going to actually paste in some lines of quote and then I'm going to explain to you
what's going on here.
So as you can see here these are the lines of code that I actually pasted here.
So now I'm going to explain to you what's going on here.
In-lens 71.
Again I need to actually access the shared preferences of my application OK shows the preferences inside
the Android to the Android device.
I am actually actually accessing that showed preferences.
And again I am actually calling this Meffert get preferences zero in order to access the shared preferences
of my device an inline 72 as you can see.
I created a boolean value of boolean value a bell and the name of this value but is checkbox value.
OK.
An assignment operator.
So here you want to assign a value to this value but right checkbox value share preferences here.
I am actually filling to the name of this object shared prevented that gets Boullion.
So I want to get a boolean value right.
And here as you can see inside the prentices of the Smurfette I have two arguments the first one is
the key.
As you can see this key is the same as this key that I actually put here in order to save this boolean
value right checkbox value.
And the second one is actually a default value.
So when the application for example fails to access the shift differences.
In some cases it can actually put the false value to this checkbox value.
OK so 99 percent of the time it's going to actually get the value of the checkbox and it's going to
actually keep this piece of code here.
This false value.
But here we need to actually put a default value or a false and in line 73.
If we have this idea of type String checkbox string value and as you can see here assignment operator
again I actually work through the name of this object shared preferences that gets stream.
So you want to get a string value.
Again as you can see we have this CI.
So this is the same as Diski.
In order to get this string value right.
So a check box takes the value.
And this is going to be strange a default value.
So when the application fails to access the show preferences in order to access these values is going
to assign this value to the text of the checkbox.
This is my check works right and in line 74.
Again I referred to the name of this checkbox object here as you can see in our main activity class
I referred to the name of the checkbox object that said check it.
So I want to actually specify the state of my checkbox.
I want to actually determine whether it is going to be checked or not checked checkbox that said checked
checkbox value as you can see here checkbox that said text checkbox string value as you can see here
I have this thing value here.
So it's going to assign these values to these checkbox here.
So now let's run our project and see what happens.
So now as you can see our application is running on this emulator here.
So now I want to actually check this checkbox.
So now as you can see this box is actually checked and the text of the search box is the checkbox is
checked.
OK so now I want to actually click on this back button here.
So now the application is actually destroyed from their memory and the unpause Moffit is actually called.
And again I want to open this application up for 50.
And as you can see here this state is actually changed.
OK.
And the resume if it is called and we can and we actually retrieved the information the checkbox is
checked and we can see that the actual checkbox is actually checked.
OK.
And now it's actually unticketed checkbox.
And as you can see this text here Solas again click on this batch button here and it's actually up for
example close this application in the background.
And again I want to actually open this application at 50.
And as you can see here this state is changed.
The checkbox is not checked.
And as you can see it is on checked right.
So hopefully that makes sense.
And I think that's enough for this tutorial.
So if you have any questions please post the discussion in the course and then I'll do my best to answer
all of your questions.
Thank you very much for watching and I'll see you in the next tutorial.