java - Best way to retrieve logged user in app -
i want retrieve current logged user in many places in android app. best way?
- save in static variable in
userclass , retrieveuser.getcurrentuser() - get dao or repository
usersrepository.getcurrentuser()
or there better way?
thanks.
in web application use standard way: request.getremoteuser()
if need have additional information user store in session:
session.setattribute("user", userobject); if using kind of application (for example mobile application) , 1 user per time can logged can use singleton store information of user:
user user = user.getinstance(); user.setname("blabla"); // store information user.getname(); // information
Comments
Post a Comment