ImageButton imgBtnSyncRes  = (ImageButton) findViewById(R.id.imgBtnSyncResponses);
		imgBtnSyncRes.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				
				File objfile=new File(getFilesDir().getAbsolutePath()+ File.separator + "/index.xml");
			
				try {
					download("ftp.qualityinaction.net/QIA/Questions/Airlines/","qualityinaction.net", "password","index.xml",objfile);
				} catch (MalformedURLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}*/
			}
		});
	}


	//File Downloading from ftp
	public void download( String strftpServer, String struser, String strpassword,
			String strfileName, File strdestination ) throws MalformedURLException,
			IOException
			{
		if (strftpServer != null && strfileName != null && strdestination != null)
		{
			StringBuffer strb = new StringBuffer( "ftp://" );
			// check for authentication else assume its anonymous access.
			if (struser != null && strpassword != null)
			{
				strb.append( struser );
				strb.append( ':' );
				strb.append( strpassword );
				strb.append( '@' );
			}
			strb.append( strftpServer );
			strb.append( '/' );
			strb.append( strfileName );
			/*
			 * type ==> a=ASCII mode, i=image (binary) mode, d= file directory
			 * listing
			 */
			strb.append( ";type=i" );
			//test(strb.toString());
			//OpenHttpConnection(strb.toString());

			BufferedInputStream bis = null;
			BufferedOutputStream bos = null;
			try
			{
				URL url = new URL(strb.toString());
				URLConnection urlc =(URLConnection) url.openConnection();
				//urlc.setDoOutput(true);
				//urlc.connect();

				//urlc.connect();

				bis = new BufferedInputStream( urlc.getInputStream() );
				bos = new BufferedOutputStream( new FileOutputStream(
						strdestination.getName() ) );

				int i;
				while ((i = bis.read()) != -1)
				{
					bos.write( i );
				}
			}
			finally
			{
				if (bis != null)
					try
				{
						bis.close();
				}
				catch (IOException ioe)
				{
					ioe.printStackTrace();
				}
				if (bos != null)
					try
				{
						bos.close();
				}
				catch (IOException ioe)
				{
					ioe.printStackTrace();
				}
			}
		}
		else
		{
			System.out.println( "Input not available" );
		}
			}

	//File uploading to FTP
	public void upload( String ftpServer, String user, String password,
			String fileName, File source ) throws MalformedURLException,
			IOException
			{
		if (ftpServer != null && fileName != null && source != null)
		{
			StringBuffer sb = new StringBuffer( "http://" );
			// check for authentication else assume its anonymous access.
			if (user != null && password != null)
			{
				sb.append( user );
				sb.append( ':' );
				sb.append( password );
				sb.append( '@' );
			}
			sb.append( ftpServer );
			sb.append( '/' );
			sb.append( fileName );
			/*
			 * type ==> a=ASCII mode, i=image (binary) mode, d= file directory
			 * listing
			 */
			sb.append( ";type=i" );

			BufferedInputStream bis = null;
			BufferedOutputStream bos = null;
			try
			{
				URL url = new URL( sb.toString() );
				URLConnection urlc = url.openConnection();

				bos = new BufferedOutputStream( urlc.getOutputStream() );
				bis = new BufferedInputStream( new FileInputStream( source ) );

				int i;
				// read byte by byte until end of stream
				while ((i = bis.read()) != -1)
				{
					bos.write( i );
				}
			}
			finally
			{
				if (bis != null)
					try
				{
						bis.close();
				}
				catch (IOException ioe)
				{
					ioe.printStackTrace();
				}
				if (bos != null)
					try
				{
						bos.close();
				}
				catch (IOException ioe)
				{
					ioe.printStackTrace();
				}
			}
		}
		else
		{
			System.out.println( "Input not available." );
		}
			}
}
