Save and Retrieve Variables from SharedPreferences | Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 39

  • @markbozinovic706
    @markbozinovic706 3 роки тому

    Superb video Subhojit. Totally practical with solid theory incorporated into it. Keep them comming! Great Work

  • @Rickbrouwerlwd
    @Rickbrouwerlwd Рік тому

    very good video helped me and i learned how it works tnx alot

  • @قناةالرياضيات-ن7ر
    @قناةالرياضيات-ن7ر 3 роки тому

    Wonderful explanation .... I hope to do many more advanced course explanations for shared preferences ....

    • @DailyCoding
      @DailyCoding  3 роки тому

      Sure, I will. But you can also request your topic also.

    • @قناةالرياضيات-ن7ر
      @قناةالرياضيات-ن7ر 3 роки тому

      First: Thank you very much for your kindness.
      I need to know more about OnSharedPreferenceChangeListener

    • @DailyCoding
      @DailyCoding  3 роки тому

      I have already created an example on that topic. So have you seen that? Would you like to see another example?

    • @قناةالرياضيات-ن7ر
      @قناةالرياضيات-ن7ر 3 роки тому

      @@DailyCoding yes, I need examples of uses for shared preferences
      SharedPreferencesBackupHelper;
      SharedPreferencesCompat;
      PreferenceFragment

    • @DailyCoding
      @DailyCoding  3 роки тому +1

      Okay! You are actually looking for a Settings screen. Right!

  • @SumanDas-ey8ro
    @SumanDas-ey8ro 4 роки тому

    Amazing...... Keep it up dude...!!!😊

  • @sanjushah8021
    @sanjushah8021 3 роки тому

    Great 👍

  • @deppakkumar659
    @deppakkumar659 3 роки тому +1

    Nice video

  • @CivilUnboxing
    @CivilUnboxing 4 роки тому

    Ohhh.. cool stufff.... 💯💯💯

  • @attilaagoston1571
    @attilaagoston1571 Рік тому

    I want to save and retrieve my Scrollview scroll position where user exit the app. How should I do that?

    • @DailyCoding
      @DailyCoding  Рік тому +1

      Just store the int value of the recycler view in shared preference. Finally in oncreate() retrieve that value and set it by calling scrollPosition(your_position). That's all.

  • @abbsswork4845
    @abbsswork4845 3 роки тому +1

    Hi sir. When I close the application in background, the saved data (in my case boolean) is lost when i reopen it. Any solution?
    Thanks

    • @DailyCoding
      @DailyCoding  3 роки тому

      Watch this video carefully. Hope it will help.

  • @khalidmahmood418
    @khalidmahmood418 4 роки тому

    I want to save coundown timer to shared preferences and coundown does not reset even on backpress or close app until onfinish

    • @DailyCoding
      @DailyCoding  4 роки тому

      Override onBackPressed method and stop your timer there. That's it.

    • @khalidmahmood418
      @khalidmahmood418 4 роки тому

      @@DailyCoding i found another working method in the mean time, thanks for your reply.

    • @khalidmahmood418
      @khalidmahmood418 4 роки тому

      Using shared preferences

    • @DailyCoding
      @DailyCoding  4 роки тому

      @@khalidmahmood418 yes, you can save timer value in that method

  • @drtamer545
    @drtamer545 3 роки тому +1

    Greate Vedio
    But, i have one Question
    Once i do Sharedpreferences in one Activity, i can't change key value from other activity? So any solution for that

    • @DailyCoding
      @DailyCoding  3 роки тому +1

      No. you can change the value from anywhere but you should use the correct cotext mode. In order to allow your SharedPreference globally available instead of single activity read/write permission.

    • @drtamer545
      @drtamer545 3 роки тому

      So, any vedio about how to change from other activity??
      I use SQLite instead

    • @DailyCoding
      @DailyCoding  3 роки тому +1

      @@drtamer545 you should create a Sharedpreference instance on another activity and use the same key as you used earlier.

    • @DailyCoding
      @DailyCoding  3 роки тому +1

      @@drtamer545 You can also use SQLite or Room if you have a complex data set.

    • @drtamer545
      @drtamer545 3 роки тому

      I tried the Same key from other activity, but can't change data inside the Sharedpreference Key

  • @abdelrahmannabil5668
    @abdelrahmannabil5668 4 роки тому

    thanks for the video
    but i have a problem when i call load method in other Activity App crash

  • @muhammadelsersy7778
    @muhammadelsersy7778 3 роки тому

    Peace
    thanks very much ,,