title: ArrayList as global variable
body: <p>I created class that extend of application like that </p>
  
  <pre><code>package com.appnetics;
  
  import java.util.ArrayList;
  
  import android.app.Application;
  
  public class GlobalVariables extends Application {
  
      public ArrayList&lt;Encounter&gt; encounters;
  
  }
  </code></pre>
  
  <p>and set it in manifist like this </p>
  
  <pre><code>&lt;application
  android:name="GlobalVariables"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name" &gt;
  </code></pre>
  
  <p>in one Actiity I fill this array using this code </p>
  
  <pre><code>GlobalVariables appState = new GlobalVariables();
  appState.encounters =new ArrayList&lt;Encounter&gt;(); 
  ................
  then add 
  </code></pre>
  
  <p>when trying to use it  it crash with null exception, I use it in another activity or class like that </p>
  
  <pre><code>    GlobalVariables appState = new GlobalVariables();
  
      Encounter EncounterObject = appState.encounters.get(position);
  </code></pre>
  
  <p>is there something missing please , how to fix that </p>