I am returning to Java after a 5 year break from it. If I remember correctly the Garbage collector would kick in and collect the 'new' memory after subsequent calls to setListAdapterStrings(String [] data)? To be more general does anyone have a preferred set of documentation they like to use when it comes to producing memory leaks while using the JVM?
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
public class MainActivity extends ListActivity {
private ListAdapter mListAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
createAdapter();
setListAdapter(mListAdapter);
}
protected void createAdapter() {
// Create some mock data
String[] testValues = new String[] {
"Hello",
"Welcome",
"The",
"Java",
"Test",
"World",
};
setListAdapterStrings(testValues);
}
public void setListAdapterStrings(String [] data) {
mListAdapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_list_item_1,
data);
}
}