How to Save Variables in SharedPreferences – Android Studio Tutorial

20
6



Today we will learn how to use Shared Preferences in Android to store data. We will use a SharedPreferences.Editor to save Strings and Booleans, but you can also save other data types like Integers, Floats or Long variables.

Example code:

____________________
❗ Subscribe to the channel:

⏯ Watch more tutorials:

⭐ Become a channel member for exclusive tutorials and other perks:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:

Facebook:

Instagram:

Twitter:

Blog:

Nguồn: https://khudothidongvan.com/

Xem thêm bài viết khác: https://khudothidongvan.com/cong-nghe/

20 COMMENTS

  1. How to use a Checkbox for this? Want to save the state of a checkbox into a shared preference, but checkbox.isChecked() isn't working.

  2. so, we don't have to remove the value first, like
    editor.remove("keytoberemoved");
    editor.apply();
    if the value changes, it will automatically changes?

  3. The best tutor you could get online……… I love you man you have made my programming life easier………..

  4. ComeOn man😊😊😊 your videos have always proved very helpful to me… This time i've been stuck at a part of my android project where i've have to save and retrieve data from the android saved instances .. after spending too much time upon looking and searching the internet regarding this issue ..got nothing really beneficial..at that moment "codinginflow" clicked in my mind and i am nowhere thanking you…😊😊😊

    This video solved my issue in no time …thanks FLORIAN.. 💖💖
    Keep it Up!!!!😉😉💖😊

LEAVE A REPLY

Please enter your comment!
Please enter your name here