Note that there are some explanatory texts on larger screens.

plurals
  1. POFTP Download in Android Extremely Slow (Fast in just Java)
    text
    copied!<p>I am downloading MP3 files from an FTP server. It is for an Android application which will download and the then play the MP3 files. The downloading is implemented in Java using apache commons library and the code is largely based on another tutorial. The download works very fast on my desktop running Java taking about 5 seconds to download a file which is ~10mb, but on the same code run on an Android device (I have tried 2) is ridiculously slower taking 5-10 minutes to download the same file. (Both tests were done over Wifi).</p> <p>Code based on: <a href="http://androiddev.orkitra.com/?p=28&amp;cpage=2#comment-40" rel="nofollow">http://androiddev.orkitra.com/?p=28&amp;cpage=2#comment-40</a></p> <p>The code below shows the two methods used: connect and download.</p> <pre><code> public boolean connect(String host, String username, String pass, int port){ try{ mFTPClient.connect(host, port); if(FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) { boolean loginStatus = mFTPClient.login(username, pass); mFTPClient.setFileType(FTP.BINARY_FILE_TYPE); mFTPClient.enterLocalPassiveMode(); mFTPClient.setKeepAlive(true); return loginStatus; } } catch (Exception e){ System.err.println("Error: Could not connect to: " + host); e.printStackTrace(); } return false; } public boolean download(String srcFilePath, String dstFilePath) { boolean downloadStatus = false; try { FileOutputStream dstFileStream = new FileOutputStream(dstFilePath); downloadStatus = mFTPClient.retrieveFile(srcFilePath, dstFileStream); dstFileStream.close(); return downloadStatus; } catch (Exception e) { System.err.println("Error: Failed to download file from " + srcFilePath + " to " + dstFilePath); } return downloadStatus; } </code></pre> <p>Hopefully I have mentioned all the details needed and would appreciate if anyone could explain why it is so much slower and how if at all I can make it download in a reasonable time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload