Android sharedpreferences tutorial

preview_player
Показать описание
In this tutorial you will about android sharedpreference api and how to use sharedpreference api to store and retrieve a color that later will be used for coloring android toolbar and android statusbar.

Here is how to do it:
- Create 3 android buttons that will each hold a color
- Make those buttons clickable by using Android setOnClickListener
- Define Sharedpreference and make sure the mode is set to private
- Define Sharedpreference.Editor to be able to edit sharedpreference file and store color
- Inside setOnClickListener store the color inside sharedpreference and use the same color for Android toolbar and Android statusbar.
That's it!!

Social media:
Рекомендации по теме
Комментарии
Автор

Yo man work....one thing that i like about you is you are coding very freely and friendly...you never worry what will happen.... you declare and use things just when they needed... you forget to give app name and you done that after the first run... i like it that you forget small small things...because that;s the sign of true again ...great job..and very good explanation. :)

tejaspatel
Автор

Man, your class and your explanation metodoly is amazing...
Tks a lot for share your knowledge.

alexandreoliveira
Автор

Thanks for the video, I learned how to use shared preferences and implemented. Moreover, I learned about Reformating Code from tutorial.

HighbrowDirector
Автор

Great tutorial! By the way, you can use the "Preview" tab on the right. The changes are rendered automatically.

SilverYagi
Автор

very thanks
like this make for select language by sharedpreference if we use 3 language like en and ar and it
but work for all activity like main activity and about activity and setting
thanks

samirdesigner
Автор

awesome explanation dude ....!! keep it up

amitrai
Автор

👍 not know properly English but understood...

faizanfangari
Автор

Can you please make another example of shared preference with login activity.

mayurmodi
Автор

may i know how about the button, now i would like to do the colour of button is permanently just like your tutorial, for example, when i click button red, the button red will become red and reopen application, the button still is red while when i click button green, the button green also will become green and same when reopen again, the button green still is green, hope can kindly reply me, very urgent for me,

lunl
Автор

Thank you so much Sir well explained the content (y)

EngineeriOSwala
Автор

Thanks a lot! It helped me in clearing my doubts :)

nihaneha
Автор

thank you :) I really like the way you teaches.. :P

priyaranjan
Автор

what about if i want to set color for entire background not to the toolbar

shaikappu
Автор

Thanks, it's working. fine but I need more activity so this. how to do please tell me.

BUGGYGAMlNG
Автор

What about if two Activities will be use? How to pass the value of shared preference to the other? Thank you

moniquenoche
Автор

Sir can you teach me how to use shared preference on image? Thank you sir

kiteljane
Автор

i am making a button clicking counter app how save click details of button

HBunseend
Автор

Why don't you just declare a method that get the view and depending on the id do something and not repeat the setOnclicklister like 300 times?
Also, why don't you deal with the deprecated items. You can use ContextCompat.getColor(context, R.color.color_name).
Just saying.

lingovilla
Автор

too long, but should only focus on preferences, not GUI, but generally thumbs up!!! thanks for sharing.

bastawa
Автор

I want to put the shared preferences in a database that only registers settings that work within the app only how would I do this?(also I am using firebase)

technofrog
join shbcf.ru