I don't think a static field is what you want here. You did not mention where this xml came from, but I assume you mean the string array specified in the xml file included in your application. In this case, you need to get a handle to the "Resources" object, and for this you need context.
The application object is always nearby and accessible from all your actions. I would create and save these global ArrayLists. Since it looks like you have a bunch, you could have a Map of ArrayLists and a function in your Application class that takes the name of the ArrayList you want and returns the corresponding ArrayList from the map.
public class MyApp extends Application { private Map<String, ArrayList<String>> mLists=new HashMap<String, ArrayList<String>>(); public void addList(String key, ArrayList<String> list) { mLists.put(key,list); } public ArrayList<String> getList(String key) { return mLists.get(key); } }
jfelectron
source share