title: Android: static variables and moving complex data
body: <p>If I have a class that contains a static variable, say x:</p>
  
  <pre><code>class MyClass {
  
      static boolean x = false;
  
      // Other methods
  
  }
  </code></pre>
  
  <p>Now let us say that, hypothetically, I set <code>x = true;</code> from my first activity. Is there any point through the rest of my app's life cycle (including various activities and threads) where this value will simple be 'reset' back to <code>false</code> due to how the 'Google JVM' or the android environment works? I have heard that static variables have a 'lifetime', that dies when the program dies. Do Activities count as separate 'programs'? What about services? Or even Widgets?</p>
  
  <p>I am asking this because it is often difficult to share complex data structures that rely on other complex processing (like syncing data from an online database) in android due to how 'separated' activities are, and static variables are often a very quick and dirty solution to the problem. Other things I have tried include serialisation, but that doesn't really seem like a practical solution either (constantly serialising and decoding objects when the user navigates from one activity to the next seems like it would be very resource intensive).</p>
  
  <p>If I am an evil person for doing this, please tell me what I am doing wrong, or even better, give me some links or examples of better ways to solve this problem. </p>