I am building an Android application that has a class User which is used for keeping the profile information of the user.
When a user is created it is saved on a SharedPreferences file so I can load the last created user then next time I start the app. I also have a Singleton class which holds the object of the newly created user so it can be used by the other classes.
I did this to avoid reading the SharedPreferences file every time I change a Fragment and the user is needed.
My question is:
Is using Singleton a proper way for keeping variables in memory for the entire application?
Was it intended for that or is there another way to do that that keeps the Object Oriented Programming principles?
Would it be better to create variables in Activity instead with accessor methods?