Notes on using static fields in Android

Here are a few notes on using static fields in Android, from this SO page. (Note: Some of the stuff on that page is very wrong.)

Because static fields live until an Android app is killed (while instance fields are destroyed a lot), I’ve been using static fields to persist some of my Android app’s “state” data, but I was just thinking that I can probably do the same thing at the Activity level using onSaveInstanceState(Bundle) and then restoring the state with onCreate(Bundle) and onRestoreInstanceState(Bundle). The correct approach really depends on the problem you’re trying to solve.

Photo D8