title: variable scope problem in android
body: <p>hi all
  i have an arraylist and array in an activity and have two function. i declared arraylist and array in activity and used in a function. but i cannot access in those variables in second function. both function is in same activity. in second function gives NullPointerException in Logcat.
  code:</p>
  
  <pre><code>public class testapplication extends Activity {
   ArrayList&lt;String&gt; getdatabase = new ArrayList&lt;String&gt;();
   public  String[] array;
   protected void onStart() {
        getdatabase.add("1");
        getdatabase.add("2");
        array=new String[getdatabase.size()];
        getdatabase.toArray(array);
        Log.e("app",""+array.length()); // print as app  2
  
     }
  
   public void onCreate(Bundle savedInstanceState) {
  
   Log.e("app",""+array.length()); // NullPointerException.
   }
  
  }
  </code></pre>
  
  <p>please help me.</p>