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 7593597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:12:34+00:00 2026-05-30T21:12:34+00:00

in my Android app I need to download a ~40 MB file, and I’m

  • 0

in my Android app I need to download a ~40 MB file, and I’m testing the code in my phone but the download speed is REALLY slow, I tried to download from different sources that are fast when using my PC.

Here is the code I use in the download service:

URLConnection conexion;
    URL url;
    int lenghtOfFile = 0;


    try {
        url = new URL("<URL>");
        conexion = url.openConnection();
        conexion.connect();
        lenghtOfFile = conexion.getContentLength();


        try {

            File f = new File(Environment.getExternalStorageDirectory() + "/testing");


            InputStream input = new BufferedInputStream(url.openStream());
            OutputStream output = new FileOutputStream(f.getAbsolutePath());

            byte data[] = new byte[1024];

            long total = 0;

            while ((count = input.read(data)) != -1) {
                total += count;

                notification.contentView.setProgressBar(R.id.status_progress, 100, (int) (total * 100 / lenghtOfFile), false);
                notification.contentView.setTextViewText(R.id.status_text, Long.toString(total * 100 / lenghtOfFile));

                notificationManager.notify(42, notification);
                output.write(data, 0, count);
            }

            output.flush();
            output.close();
            input.close();
        } catch (Exception e) {
            e.getCause();
            e.getMessage();
        }


    } catch (Exception e) {
    }


}

Is it possible that this code is the reason of the slow dl speeds? Any ideas on how to make the download speed faster?

  • 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-05-30T21:12:36+00:00Added an answer on May 30, 2026 at 9:12 pm

    change this

    byte data[] = new byte[1024];
    

    to

    byte data[] = new byte[4096];
    

    and as commonsware said,
    update your download progress notification in less frequencies.

    for eg:
    use a simple counter variable in your loop, and update progress when it reaches 10, and then resetting it..!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an Android app and I need to download a csv file
I need to write an Android app that would download sounds from the internet
I'm writing an android app and I need to read several files from several
I'm making an Android app where the user can download files from a FTP-server.
i want to launch an intent from android website what code do i need
In my app I need to download files from url locations. I want to
I am developing an app for android where I need some data from a
My android app project need to add a new function of saving the click
Android Calendar App I need to be able to implement a view similar to
To create facebook android native app we need to provide our Android application signature

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.