In the following code i have a Class that contains a bunch of variables. I create a couple of instances of that class and save them to an arraylist. The arraylist is part of the same class, but marked static. The same app has a homescreen app widget. I worry that the static arraylist will stay in memory forever until the user deletes the app widget. Is this true? Is the static arraylist a good idea or what could be an alternative?
public class Data {
public static ArrayList<Data> listData = new ArrayList<Data>();
String string;
int integer;
Data(String string, int integer){
this.string = string;
this.integer = integer;
}
}
public class DataChanger {
DataChanger(){
Data.listData.add(new Data("string", 1));
}
}