Answer the question
In order to leave comments, you need to log in
Data recovery after app restart?
Good afternoon! I am developing a fairly large client-server application, and I encountered such a problem.
The user, upon entering the application, is authorized, and then continues to work. User data is stored in the singleton manager as an object of the UserData class, which stores personName, logo, etc. Also, a Map is stored, in which the connection session to the server is stored (roughly speaking, cookies). The singleton was not chosen by chance, since the interaction with UserData is distributed throughout the application, and it will be very cumbersome to pass this information to the Intent as Parcelable, in addition, there must be one instance, everywhere in the application.
The problem is this - after the task is destroyed by the system, and the user tries to open the application from recent - android will try to restore the last state of the application (last activity, activity task, savedInstanceState), and the UserData singleton will be null, because. this info was not saved.
I ask for help, how to solve this problem with little bloodshed?
Answer the question
In order to leave comments, you need to log in
if only for storing a token and the like, then you can just share preferences, a singleton is still not the best solution, although it depends on the implementation and architecture, but I try to avoid this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question