i want to download a xml file file ,from the following url :"http://nchc.dl.sourceforge.net/project/trialxml/options.xml"
===

i am new to android java, cn neone help me with this download..
This is what i m trying.
everytime i m running this app, it is shutting down immediately i press my download button, so is there a run time error in the following code?


    File xml;
    private String down_file="options.xml";
    private Context context;
    URL url;
    URLConnection connection;
    url=new URL("http://sourceforge.net/projects/trialxml/files/options.xml");
    xml=new File(context.getCacheDir(),down_file);
    try {
    	connection=url.openConnection();
    	connection.connect();
    	InputStream stream=connection.getInputStream();
    	if(stream==null)
    	{
    		Log.e(TAG,"uanble to create Input stream for the url" + url);
    	}
    	FileOutputStream fos=new FileOutputStream(xml);
    	byte buf[]=new byte[128*1024];
    	do
    	{
    		int numread=stream.read(buf);
    		if (numread<=0){
    			break;
    		}
    		else{
    			fos.write(numread);
    		
    		}
    		
    	}while(true);
    	fos.close();
    	
    }
    	
    	catch(Exception e){
    		System.out.println("cannot download the xml file");
    		e.printStackTrace();
    		
    	}
    
    
    
    }
    
    
    
    
}

