public void oncreate(){ // Do something or mostly the basic code // Call the class to initate the connection and get the data FetchList fl = new FetchList(); fl.execute(); } //Always better to use async task for these purposes public class FetchList extends asyncTask<Void,Void,Byte>{ doinbackground{ // this was explained in first step Response res = new Response("url"); String response = res.getResponse(); XmlParser xml = new XmlParser(response); ArrayList<item> itemList = xml.getItemList(); xml.parse(); } }