Skip to content

Tag: sharedpreferences

Why does the Recycleview work differently when I start it or when I go back to it from an other activity?

I try to create a Shopping/ToDoList application where the items are contained in SharedPreferences. When I start the application, and I choose what I want to execute, Shopping list part or ToDoList part, then the java code fetches the existing data from the SharedPreferences and give to the RecycleView to create and show a list. It seems works totally correct,

Is SharedPreferences necessary for all data?

I am new in Android. I have a database like this. I used SharedPreferences for remember user information. However, there is a point that I do not understand. When the user logins the application, do I need to save all Firebase data in SharedPreference for the application to remember the user? Which type of datas save in SharedPreference? I just

Deleting an item (index) from SharedPreferences

I’m saving an array called semesterArray which is a List<String> semesterArray = new ArrayList<>() with the following method on SharedPreferences: The if statement is there to update the SharedPreferences, I got the idea from this StackOverflow answer. Now, the following method takes care of loading the SharedPreferences that were just saved: We remove duplicate Semesters because the if statement in

How can I make SharedPreferences to update the data instead of overwriting the data and losing part of it?

I’m using the following piece of code to save an ArrayList<String> into SharedPreferences: This is somewhat getting the job done since it saves the ArrayList<String> as intended and when the app is re-launched the Semesters that were added are still stored in the ArrayList<String> as I want them to be. But if I add more Semesters after re-launching the app,