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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:06:16+00:00 2026-06-10T18:06:16+00:00

I have an app that periodically downloads a very small text file (10 bytes)

  • 0

I have an app that periodically downloads a very small text file (10 bytes) via FTP, then uploads a larger one (200-ish bytes). It does this using alarm manager, and seems to work well. I’m wondering if I need to run it on a different thread, in case the internet becomes congested, or am I being over cautious? Here’s the code for the FTP download:

 public void getFTP(Context context)
 {
  //
  // Download config.txt file from server
  //
   FTPClient ftpClient = new FTPClient();

 try{

 ftpClient.connect(InetAddress.getByName(ipAddress));  
 ftpClient.enterLocalPassiveMode();
 ftpClient.login("user", "pass");
 ftpClient.setFileType(FTP.ASCII_FILE_TYPE);

 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("/sdcard/config.txt"),8*1024);

 boolean status=ftpClient.retrieveFile("config.txt", bos);

 if(status){
     Toast toast = Toast.makeText(context, "Downloaded config.txt!", Toast.LENGTH_SHORT);
     toast.show();
     }
     else {
     Toast toast = Toast.makeText(context, "Cannot download config.txt!", Toast.LENGTH_SHORT);
     toast.show();  
     return;
     }

 bos.flush();
 bos.close();

 ftpClient.logout();
 ftpClient.disconnect();

 }

 catch (IOException e){
     Toast.makeText(context,"Connection error!" , Toast.LENGTH_LONG).show();
 return;
 }
  • 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-10T18:06:18+00:00Added an answer on June 10, 2026 at 6:06 pm

    If the question is “Should I make network connection in non-UI thread, even if they are small” – than the answer is Yes, for sure.

    Because starting from ICS, for example, Android will prohibit network connections from UI thread and will throw the exception if you will try.

    Besides, it’s just a very good practice to separate all possibly-long tasks to another threads. And ‘long’ I think is > 300ms (Android will start to push warnings in logs if any Handler’s method will be longer than 300ms, for example).

    Note: If you will start async operation inside on AlarmManager callback – be ready that system may “sleep” and hibernate, even if you’d told AlarmManager to wake up for event. You can read about this behavior here: http://developer.android.com/reference/android/app/AlarmManager.html in the top header, paragraph 2.

    Good luck

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

Sidebar

Related Questions

I have a small app that periodically needs a table row added to the
So I have a small C# app that needs to periodically check the contents
I have an App that downloads and displays images from URL's. This works fine
I have an app that allows users to upload large data files and then
I have been trying to write an app that periodically parses the contents of
I have an iOS app that connects to a server periodically looking for data
I'm writing a BackgroundAgent for my WP7 app that periodically downloads an image from
We have an Android app that periodically polls for data and updates the display.
i have a function in a php web app that needs to get periodically
I have a UITableView in my iOS app that gets refreshed periodically. The user

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.