I just discovered an apparent gap in my Android/Java understanding. In particular, it appears that static class variables are preserved between different invocations of my app.
Is this to be expected?.
I did a diligent search of StackOverflow and elsewhere but I can find no mention of this. As an experiment, I tried the following code in my initial Activity:
static int MyCount;
...
public void onCreate(Bundle savedInstanceState) {
Log.d( "MYAPP", "MyCount="+MyCount );
MyCount++;
...
If I exit the app (via finish()) and restart it, MyCount keeps getting incremented. This surprised me. Is this an expected behavior?
(and please, no lectures on the evils of static variables :)