Lifetime of a static variable in Android

前端 未结 14 2260

when I declare and initialize a variable as static in my main activity and the activity gets destroyed. Can I still access the content of the variable?

For example t

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 10:05

    If the process is killed then all static variables will be reinitialized to their default values.

    This is mainly because, when you restart the application, a new instance is created and the static variable will be reinitialized.

提交回复
热议问题