How to declare global variables in Android?

前端 未结 17 2954
死守一世寂寞
死守一世寂寞 2020-11-21 04:12

I am creating an application which requires login. I created the main and the login activity.

In the main activity onCreate method I added the following

17条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-21 04:45

    If some variables are stored in sqlite and you must use them in most activities in your app. then Application maybe the best way to achieve it. Query the variables from database when application started and store them in a field. Then you can use these variables in your activities.

    So find the right way, and there is no best way.

提交回复
热议问题