I'm developing an application on Android that connects to a FTP server to upload and download files. To make the connection I'm using the apache commons-net library's FTPClient class based on this and I'm working on Eclipse.
But I get the following message on my Logcat:
07-04 21:11:44.196: D/USB Virtual(14708): Error: could not connect to host ftp://xxx.xxx
The following is my manifest permissions:
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
I'm really lost as to why I can't connect to my FTP server, in the console there're no errors showing. Am I missing something? I would thank any help.
I'm adding the code I'm using to connect to my FTP server:
public boolean ftpConnect(String host, String username, String password,
int port) {
try {
mFTPClient = new FTPClient();
//host is ftp://looner-project.zxq.net
mFTPClient.connect(host);
mFTPClient.connect(InetAddress.getByName(host));
if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
boolean status = mFTPClient.login(username, password);
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
return status;
}
} catch (Exception e) {
Log.d(TAG, "Error: could not connect to host " + host);
}
return false;
}