Service Provider → QuickEmailVerification Zoom BriteVerify Xverify NeverBounce KickBox DataValidation
Criterea ↓
Price per 250,000 credits $660 $250 $2,000 $750 $750 $750 $750
Free Trial Available YES YES NO NO YES YES NO
Free Credits 3,000 Credits Per Month NIL NIL NO 1,000 API Credits (List verification is not free) 100 Credits One-Time NO
Delivery Accuracy 95%+ 98%+ N/A N/A 97% 95% N/A
Time Taken 75 minutes for 100,000 credits 1 hour on average (the system can detect even greylisted domains, that require, in most cases 1h delay) 100-110 minutes for 100,000 credits 120 minutes for 100,000 credits 90 minutes for 100,000 credits 90 minutes for 100,000 credits 130-140 minutes for 100,000 credits
Auto Correction YES YES N/A YES N/A YES NO
Signup Requirements No Further details required Email LinkedIn profile or personal details required Credit Card details required No Further details required No Further details required No Further details required

Objective

Main objective of this post is to give an idea about how to start FTP in Android

 

What is FTP ?

File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one host to another host over a TCP-based network, such as the Internet. FTP is built on a client-server architecture and uses separate control and data connections between the client and the server. FTP users may authenticate themselves using a clear-text sign-in protocol, normally in the form of a username and password, but can connect anonymously if the server is configured to allow it.

For secure transmission that hides (encrypts) the username and password, and encrypts the content, FTP is often secured with SSL/TLS ("FTPS"). SSH File Transfer Protocol ("SFTP") is sometimes also used instead, but is technologically different.

Following are the steps to start FTP in Android device:

 

Step 1 Download Required .jar files.

First you need following JAR file:

1. commons-net-3.3.jar

Download latest jar file and add into libs folder of your Android project.

 

Step 2 MyFTPClientFunctions class

Create new class MyFTPClientFunctions into your project. Now add some FTP functions into newly created class.

  • public FTPClient mFTPClient = null; // Add top of the class

Now add method to connect FTP server. (Method to connect to FTP server)

public boolean ftpConnect(String host, String username, String password, int port) {


try {



mFTPClient = new FTPClient();





// connecting to the host
mFTPClient.connect(host, port);





// now check the reply code, if positive mean connection success
if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {





// login using username & password


boolean status = mFTPClient.login(username, password);




<p>	/*
* Set File Transfer Mode

* To avoid corruption issue you must specified a correct
* transfer mode, such as ASCII_FILE_TYPE, BINARY_FILE_TYPE,
* EBCDIC_FILE_TYPE .etc. Here, I use BINARY_FILE_TYPE for
* transferring text, image, and compressed files.
*
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
<p>	return status;
}
} catch (Exception e) {
Log.d(TAG, "Error: could not connect to host " + host);
}
return false;
}</p>

Now add method to disconnect FTP server. (Method to disconnect from FTP server)

<p>	public boolean ftpDisconnect() {
try {
mFTPClient.logout();
mFTPClient.disconnect();
return true;
} catch (Exception e) {
Log.d(TAG, "Error occurred while disconnecting from ftp server.");
}
return false;
}</p>

Now add method to upload file on FTP server.

<p>public boolean ftpUpload(String srcFilePath, String desFileName,
String desDirectory, Context context) {
boolean status = false;
try {
FileInputStream srcFileStream = new FileInputStream(srcFilePath);</p>
<p>	// change working directory to the destination directory
// if (ftpChangeDirectory(desDirectory)) {
status = mFTPClient.storeFile(desFileName, srcFileStream);
// }</p>
<p>	srcFileStream.close();</p>
<p>	return status;
} catch (Exception e) {
e.printStackTrace();
Log.d(TAG, "upload failed: " + e);
}
return status;
}</p>

More methods are in full demo project.

 

Step 3 Call FTP Functions

Calling of above FTP functions. Create new class which extend Activity.

Add following into your class:

private MyFTPClientFunctions ftpclient = null;

Now add following into onCreate:

ftpclient = new MyFTPClientFunctions();

For start FTP connection:

Note

Every FTP connection call in new Thread

<p>new Thread(new Runnable() {
public void run() {
boolean status = false;
// host – your FTP address
// username & password – for your secured login
// 21 default gateway for FTP
status = ftpclient.ftpConnect(host, username, password, 21);
if (status == true) {
Log.d(TAG, "Connection Success");	} else {
Log.d(TAG, "Connection failed");
}
}
}).start();</p>

For terminate FTP connection:

<p>new Thread(new Runnable() {
public void run() {
ftpclient.ftpDisconnect();
}
}).start();</p>

If you have got any query related handling FTP in Android comment them below. Other FTP functions are in full demo project.

Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Android App Development Company in India.

I am professional game developer, developing games in unity (for all platforms). I am very passionate about game development and aim to create addictive, interactive, high quality games.