Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9325037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:44:48+00:00 2026-06-19T04:44:48+00:00

I am downloading MP3 files from an FTP server. It is for an Android

  • 0

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).

Code based on: http://androiddev.orkitra.com/?p=28&cpage=2#comment-40

The code below shows the two methods used: connect and download.

    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;
}

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T04:44:50+00:00Added an answer on June 19, 2026 at 4:44 am

    Stumbled accross a similar issue, solved it by changing the download buffer size.

    What was strange is the same code was very fast on Android emulator x86, but painfully slow on the real device.

    So, before calling the downloading function retrieveFile
    add a line like this:

    mFTPClient.setBufferSize(1024*1024);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application where I am sequentially downloading mp3 files from a server,
System.out.println(s.toString().substring(0,s.indexOf(.mp3))); i am downloading file from android application.. i need to name them as
I am developing an application, that has a module downloading MP3 files from a
In my application i m downloading some (mp4 or mp3 ) files from the
I am developing the application which is also downloading and saving mp3 files on
After downloading files from a remote UNIX FTP server, you want to verify that
I have an app with in-app downloading. I successfully download mp3 files in this
I am downloading files from my server, saving them to device, and displaying them
i am downloading an application in Android using the DownloadManager class. When the download
I plan to use ASIHttpRequest for downloading files from back-end server. Before actions, post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.