An application share preferences.
So an insight is uncreate method.
We need to actually initialize these typeface objects phone number one phone number two and number three.
So inside is uncreate me.
I'm going to actually paste in some lines of code 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.
As you can see in line 47 I actually referred to the name of this type phrase object that I actually
declared in line to anyone inside our main activity class.
As you can see here inside our uncreate Meffert I want to actually instantiate this phone number of
an object assignment operator.
So I refer to the name of this class typeface that create from asset.
So first we need to actually access the assets folder in our project.
So in our projects project structure I have these assets folder here.
So this good assets actually allow us to access this folder.
And for the second argument we need to specify the path to our front.
So inside these assets for that I have this Fornes directory.
So Faunce slash.
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.
And again I am actually instantiating this form to number two object assignment operator typeface that
creates from set get assets Faunce as you can see here Faunce Fauntleroy Brown that PTF.
So here as you can see I am instantiating this form to number two object again typeface that create
from aset get assets and here as you can see Fornes slash Fauntleroy Brown that CTF and inline 14:9
again as you can see I am instantiating this phone number of the object.
Assignment operator typeface that creates from assett get assets and here as you can see in say to double
quotes for the second argument I am actually giving the path of the front Faunce slash wunderbar space
them all that Auty at.
So now that I actually specified the the my forms and I actually instantiated my phone's objects.
Now I want to actually override the Andrys your method.
So unless you have it in my main activity class Ok so I can just type on resume and the autocomplete
feature of the Android studio is going to help me to actually select the Smurfit and then press on Enter
key on my keyboard.
So now as you can see I actually overwrite the Smurfit so now and they don't actually work on this on
a resume if it later.
OK in this tutorial but for now let's actually go back again inside this uncreate method and this time
I want to instantiate these shared preferences object.
OK.
So inside this uncreate method I'm going to actually pasting this line of code here.
So as you can see here this is the line of code that I actually paste that here.
And first of all I've referred to the name of this object that I declared in my main activity class
inline 32 as you can see here.
So now inside these uncreate Meffert I am instantiating this object shared preferences assignment operator.
So I've referred to the name of this preference manager class that get shared preferences.
So this object is going to help me and help me to actually save some data inside the shirt.
Proofer and says And whenever I actually I need them I can actually retrieve those data.
So preference managers that create a default shared preferences and in say the practices of this Meffert
we need to actually specify the context.
So the context is going to be the main activity that is.
So now I successfully instantiated these shared preferences object.
So remember let me explain again these shared preferences.
Object is going to help me to save and retrieve data in my application server.
For example when the user changes the format or for example when the user increases the size of a takes
few of you can actually save those information inside the shirt preferences and we can actually retrieve
those information and use it for example closes.
It closes the application and and later.
For example the use that often is the application.
And we can actually retrieve those saved data that are inside these shared preferences so we can actually
use this object in order to save and retrieve data in our application.
So now inside our main activity class I'm actually pasting some lines of code here and then I'm going
to explain to you what's going on here.
So here I'm going to paste in a method.
So as you can see here these are the lines of code that I actually pasted here.
This is actually a method.
And as you can see here in lines 69 flew 94.
Actually MF it.
OK.
So I'm going to explain to you what's going on here.
So as you can see here first about the access modifier of my method inside the main activity class is
actually Puplick the return type is void.
So this is going to actually return nothing.
And the name of this effort is specifically the font for text you want.
OK so the purpose of this if it is is to actually specify what kinds of fonts you want to actually use
for our text view one.
OK.
Well we actually select a font and and if it is going to actually do its job for us.
OK so let's see what are the lines of code.
What is the logic inside this effort.
So first of all as you can see I created this bully invaluable and as you can see here the name of this
boolean boolean value but is Phone number one for text view for text that takes one value as you can
see here.
This is actually a boolean value variable and as it as you mean no Boolean value it can only hold true
or false values.
Ok so the name of this variable is false.
Number one for takes one value.
OK.
And we have another boolean valuable and the name of this variable is false.
Number 2 for text 1 value.
OK.
And we have another really invaluable phone number free for text 1 value.
OK.
So inside is some of it as you can see here.
I am actually instantiating this these bullion valuables that I created here.
So again I'll fair to the name of this phone number one for text one value here.
Assignment operator so shared preferences as you can see here we have these shared preferences.
So remember in our emulator Let me show you.
So let's actually do on our project now and in our emulator I want us actually to show you something
in here.
So now as you can see our application is running on this emulator here.
Right.
So if I click on this I mean your button here and click on these settings here.
Now as you can see this is the settings.
This is the this is actually a preference category for our ticket number one sitting right.
So here as you can see I have free phones.
So if we actually select this phone here and uncheck this phone here I want to actually for example
choose this format for my text Vonte value for my text you want.
So as you can see here if I actually as you can see if I select this checkbox the value of this checkbox
is TLOU is true right.
And if I unchecked this checkbox now the value of this checkbox is false.
Ok this is very important when it's actually checked.
It is true.
And when it's unchecked it is false.
So if you actually check this checkbox and actually come back you've in here that effect it must actually
happen here or the text you want.
This is text number 1 right.
So here as you can see I have these boolean value Burleigh's here that's actually going to hold.
Those are true or false values.
For example when the user checks the phone number one of you all for example is foreign.
So remember this is false.
Number one this is phone number two this is phone number free.
Right.
As you can see here.
So for example if to use a check this checkbox that is Phone number one as you can see here that's valuable
here.
Phone number one for text one value here as you can see this is anti-bully right.
That's that value that's valuable is going to actually hold true value.
OK this is really important.
Or if they use it for example or checks this checkbox and unchecked this checkbox here it is a second
variable here is going to actually hold true valuable.
And this first one is going to hold a false value.
This second valuable is going to hold a true value.
The first one is going to hold as you can see here.
This first one which is checked is going to hold a false value.
Right.
So let's see what what we are doing here.
So front number of on four takes one value assignment operator shared preferences.
So this is the share of preferences for actually accessing it and actually saving the data in our application.
So this is really important shared answers that get Polyana.
So here we want to get the boolean value OK checkbox Faunce number one text 1.
So this is the key.
So this key is actually inside these preferences underlined find that XML here I specify this key here
for this.
For example for this front here that is related to this text number one settings inside this preference
category of this takes number 1 settings.
This is that she checks checkbox format number of one text one as you can see here.
So this is the kid in order to access this.
Actually this checkbox it's OK in order to access the value of this tick box preference.
So he said this an activity that I will find here.
I am actually getting the boolean value if the user checks text that checkbox here.
As you can see if I unchecked this checkbox and if the user checks this checkbox here that is for another
one event.
When we call these shared preferences that get bullion is going to actually return our true value as
you can see here.
It's going to return this true value because I checked this checkbox.
So here as you can see pretty answers that get bullion.
This is the key.
And here I have this false value.
This is actually a default value.
If the application fails to access the share preferences.
So this is not going to happen.
But if that happens it's going to actually assign the value falls.
But don't worry about this always it's going to actually give you the right value.
And here as you can see I have this phone number two for text 1 value.
So as you can see here this is number one sitting right.
We are inside this as you can see inside these preferences Underland Follet find that example here of
your insight this category preprinted skeptically that is for these takes.
Number one settings.
And here I want to access this checkbox the second checkbox that holds this fall Fauntleroy down here
as you can see.
So in this minute if the date of a file here I'll refer to the name of this valuable phone number two
for text 1 value assignment operator.
So here I want to get this boolean value.
So in my emulator here if they use that uncheck this checkbox and checks this checkbox here the value
of the check box is true now right.
Shall share preferences that get bullion.
Now I actually fell to this to this key here that I actually put inside this pretty Francis underlined
file that example here.
As you can see this is that key.
And inside this main activity of a fight here I used that key in order to access its value in order
to access this.
True or false value if the user takes this checkbox the value of this checkbox is now true if the user
undertakes this checkbox the value of this checkbox is false.
OK.
And it's going to get that value.
And here is the default value.
And here I have this phone number free for text 1 value assignment operator shared preferences that
get boolean.
Again as you can see we have this key for the first form.
So in say disproove Francis underlined files that examine as you can see here you are accessing this
checkbox here of this take box preference for the form.
As you can see this is the number of free.
And in say this me an activity that I will find here we want to access that form.
So here in our emulator if the user checks this checkbox this is the number of free write this checkbox
is going to actually hold the value true.
And if the user unchecked this checkbox this checkbox is going to actually hold the value for its social
preferences that get bullied and this is the key.
And this is the default value.
And here I created some if statements.
So here I am saying that if the value of this phone number on four takes one value this boolean value.
But as you can see here if the value of this phone number one for takes one value is actually true.
It's going to actually set the typeface for this text the number text the text number one here.
So in our emulator here if you click on this back button here as you can see if the user checks the
box at this chunk file format right.
This is for another one.
And here you refer to this valuable if number one for takes one value is true.
So if the user checks this checkbox if I click on dispatch button here that actually that changes is
going to happen.
And this takes you here the front of the stakes you must change to what.
To this vault number one.
So this four to number one I actually hold declare this one to not number one in our main activity class
as you can see.
And inside on our create method inside this uncreate Meffert I instantiated this actually.
I instantiated this for another one here as you can see here typeface that create from asset get assets.
So here as you can see I'll refer to the front Faunce slash chunk 5 that ATF right.
So I have this front here.
And as you can see here in our statement here in inside our Meffert specify the font for text view 1
I created this statement and I am saying that if the value of this phone number of one for takes over
takes one value is true then a set the typeface for this text number one.
This takes you here as you can see set the typeface for this Tillich's the text number of on two fronts.
Number one right.
If this is true.
Set the typeface to front number one.
And I have another as if statement so as if this is if means that it is a valid expression here.
This condition here is false.
And then it's going to check this condition here else.
If the value of this value but the number to four takes one value is actually true then it's going to
actually assign this typeface to the text number to that set typeface for the number two.
And we have other else if so if this condition again fails if this condition here is false then it's
going to check this condition here else if for another fee for takes one value is true then it's going
to execute this line I've got here.
He actually takes a number of that set type face for another free.
OK.
So now let's actually so here is RMF it right.
So now that I have this method this specify the form for takes one method.
Now I need to call the Smurfette.
But in my quote which place is going to be the best place to call this fit inside this is your method
that we actually override that inside our main activity class as you can see here.
This is the resume of it.
So let's actually create a toast here in order to show to the user of this if it is going is going to
be called so toast that takes that make.
First of all we need to pass the context main activity that this comma and here is the text that you
want to show to the user.
And now inside the double quotes I can just typing this on Raise your Meffert this on resume Mefford
is called and then for the first argument we need to specify the duration length short that short.
So we need to call this shawm effort on this object in order to show this to the user.
So let's actually click click on run here and then click on OK.
So now as you can see our application is actually running on the simulator and the on resume effort
is called Right.
So if you actually click on the menu button here and then click on settings and here for example check
this checkbox here as you can see and then click and back again this will resume if it is called Right.
So this is you if it is going to be the best place to call this specify the format for text view you
one it.
OK this is the best place on the resume it.
So if we call this Smurfette here specify the font for text view one.
Now let's actually run our project and see what happens.