Aug 29, 2011

Androit : FTP operation (connection, upload, download ,list,etc)

Android SDK does not provide FTP connection, so that We need to use external library for FTP operation, There are various option available for FTP connection like Apache, Here I am using ftp4j. I choose ftp4j because it's very lightweight api/jar file, the FTP library size is almost 70 KB. ftp4j provides listener (FTPDataTransferListener) to check progress of uploading or downloading.

Click here to download ftp4j library

To Test my android ftp demo application you need to have FTP Host Url or IP and FTP username and password.

Here is the uploadFile function, just pass File object which you want to upload, FTP_HOST, FTP_USER,FTP_PASS are static final String object, you need to replace value of there variable before test the android ftp demo application

public void uploadFile(File fileName){
		 FTPClient client = new FTPClient();
		try {
			client.login(FTP_USER, FTP_PASS);
			client.upload(fileName, new MyTransferListener());
		} catch (Exception e) {
			try {
			} catch (Exception e2) {

Click Here to download full source code.

Note: Click on File select download original.