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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:10:40+00:00 2026-06-10T03:10:40+00:00

I have an application where a user can backup/restore his files to/from a server.

  • 0

I have an application where a user can backup/restore his files to/from a server.

During the restore operation, before downloading each file, I check if the file already exists (assuming I know the original path).

boolean fileExists(String path);

If the file exists, I want to ask the user if he wishes to download and rename, download and replace, or skip the current file.

This could be a custom AlertDialog for example (using AlertDialog.Builder and an xml layout).

So the code would be something similar to:

static final int DECISION_NO_ANSWER = -1;
static final int DECISION_RENAME = 0;
static final int DECISION_REPLACE = 1;
static final int DECISION_SKIP = 2;

int userDecision;

for (RestoreFile file : ListOfFiles) {
    userDecision = DECISION_NO_ANSWER;
    if (fileExists(file.getOriginalPath())){
        OptionsDialog.show();
        // wait for answer
    }

    switch(userDecision){
        // handle different cases and update ProgressBar
    }
}

Of course this code should be running in a separate thread.

If I use an AsyncTask here’s how I would wait for the answer:

while(userDecision == DECISION_NO_ANSWER){
    try {
        Thread.sleep(30);
    } catch (InterruptedException e) {}
}

If I use a Thread I could use wait() and notify(). I would have to use a Handler to update the ProgressBar.

So which is better (AsyncTask or Thread) ? or is there a third better solution?

  • 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-10T03:10:41+00:00Added an answer on June 10, 2026 at 3:10 am

    An asynctask is run in a thread, like everything. you can use wait and notify, with a handler or the onProgressUpdate to notify the progressBar and everything.

    • 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 for each object the user can specify his own
I have an application where a user can upload files and associate the files
I have a web application where user can create his/her account.I want that user
I have an application where the user can dynamically switch between locales from the
I have a web application where user can post url to have his file
I have an application where the user can write up some questions and add
I have a application whereby a user can destroy other users attached to the
Currently I have a web application where a user can use dropdown lists to
I have an view-based application where the user can do a lot of customization
I have a text to speech application where the user can select a language

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.