Hey there.
Well now it's time to use shared preferences in our application of cool time.
Mm hmm.
We will create another activity in our application settings activity that is the activity over the application
settings.
And we will use those settings so that the user can set the background color of the application.
Also for example Kern said the default time a time said the ringtone select from several tunes.
And for these will take advantage of such an android feature as settings.
There is an article on settings on the android developer site and it is written here that settings allow
users to change the functionality and behavior over the application settings can change their background.
What I want to do in our application.
You can also said how often the application synchronize its data with cloud storage.
That is that the server can change the content or presentation of the user interface and settings are
saved in the shared preference excel file in the form of key and value pairs.
And that is if user selects some settings then the value in this file changes and after that when you
restart the application or after turning over their phone their settings will still remain in this file
and they will remain unchanged until the user changes them again.
We will use the reference fragment class for settings more precisely its new version preference fragment
compact as you see here it is written in red.
That class was deprecated in API level twenty eight that is this class is no longer recommended to be
used since it is obsolete.
And further this class may disappear and instead they recommend using preference fragment compact preference
means settings that is saving data in the shared preference file was originally invented in order to
save you the sentence.
These class preference fragment as well as the new class reference fragment combat they inherited or
extends from the class fragment What are fragments here on these type describes the concept of fragments
in Android.
Fragment is the behavior of a portion of the user interface inside a fragment activity.
You can combine several fragments in one activity to build multiple panel UI using a user interface
and you can use fragments in different activities several times.
That is you can think of a fragment as module a section of an activity that has its own life cycle or
receive its own input.
Events and in which you can add or remove these fragments while activities writing further the design
philosophy philosophy is described and it is written that the fragments were introduced in Android 3.0
API eleven eleven and they were mainly introduced to support the more dynamic and flexible a UI design
on a large screen such as tablets.
Since the screen of the tablet is much larger than the screen of the phone there is more space on a
tablet to combine and replace user interface elements and fragments are low.
These is designed to be done without managing complex changes in the view hierarchy dividing their sizes
of activity into fragments.
You get the opportunity to modify their appearance over the activity during runtime.
That is while activity is running and safe these changes.
And here is an example of how to your eyes to.
User Interface modules defined as fragments can be combined into one activity for tablet design that
is or can be used separately for phone design.
As you can see here in the left picture activity a light activity of tablet contains fragment a and
fragment B at the same time since large screen of the tablet is white and the same fragments can be
used in different activities when displayed on the phone.
That is fragments a little more flexible design and user interface.
My both preference fragment and preference fragment compact.
Let's go to these class.
They both are in heritage.
From that fragment class from the general class but the preference fragment is used to display the fragment
with the settings in this fragment.
The user will be able to set various application settings.
I think there is enough theory and let's start implementing this in our application and then everything
will become more clear.