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:
public class testapplication extends Activity {
ArrayList<String> getdatabase = new ArrayList<String>();
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.
}
}
please help me.