Use application class for global variables

Is there any reason not to use the Application class to exchange variables in an Activity?

For example, a DB descriptor or a single HttpClient.

+3
source share
2 answers

According to the official documentation, "you can use it to maintain the state of the global application." IMO, you would not want to hold too many heavy objects around the world. Of course, "too much" is too fuzzy :) There are other ways of sharing (persistent) data: "Settings", "Database", "Files". You might want to check if any of them are suitable for your problem.

, Application - . , , , , ,

!

+5

Application , . HTTP- , , Application.

, , , Activity . Application, , , .

+3

Source: https://habr.com/ru/post/1726964/


All Articles