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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:26:03+00:00 2026-05-15T10:26:03+00:00

I have a large data file, which is zipped, and approximately 20MB. When it’s

  • 0

I have a large data file, which is zipped, and approximately 20MB. When it’s unzipped, it’s up to about 50MB. The following source code works fine. I found the original on the web somewhere else and modified it a bit. And this method is called within the AsyncTask.doInBackground.

So, what I want to know is, how can I save the on going status(? sorry, I don’t know the proper English word) and resume the procedure later? I mean, this method takes a bit long time (about a minute on an emulator), and I know there is no way since the data is kind of huge. So, if a main activity of this method gets killed, I want to save the current status of decompressing the file, and when the activity gets active, I want to resume decompressing from the last point. Hope my explanation clears my intent.

I was thinking using a service, but I also want to interact with UI, such as showing a progress or whatever. I can’t find good information to do that in the service when I roughly scan the reference, but is there a way to do that in the service? And do you think I should use it?

Anyway, my main point is how to resume decompressing a file.

private final static int CHUNK_SIZE = 32 * 1024;
byte[] _fileIOBuffer = new byte[CHUNK_SIZE];

public void unzipFile(DBFileDownloader downloader, File zipFile, String directory) 
    throws IOException
{ 
    ZipInputStream in = null; 
    FileOutputStream os = null; 
    try 
    {
        in = new ZipInputStream (new FileInputStream(zipFile)); 
        ZipEntry entry = null; 
        while ((entry = in.getNextEntry ())!= null) 
        { 
            String entryName = entry.getName();                 
            if (entry.isDirectory ()) { 
                File file = new File (directory, entryName); 
                file.mkdirs(); 
            } 
            else { 
                File file = new File(directory, entryName);
                if (file.exists()){
                    file.delete();  // I don't know how to append, so delete it always
                }
                os = new FileOutputStream (file); 

                int bytesRead = 0; 
                while ((bytesRead = in.read (_fileIOBuffer))!= -1) {
                    os.write(_fileIOBuffer, 0, bytesRead);
                    // progress procedure
                }
                os.close();
            }
        }
    }
    catch (FileNotFoundException e) {        
        Log.v("unzip", e.getMessage());
    } 
    catch (IOException e) {
        Log.v("unzip", e.getMessage());
    } 
    finally{
        if (in != null ){
            in.close();
        }
        if (os != null ){
            os.close();
        }
    }
}       

Thanks in advance,
yokyo

  • 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-15T10:26:04+00:00Added an answer on May 15, 2026 at 10:26 am

    So, if a main activity of this method
    gets killed, I want to save the
    current status of decompressing the
    file, and when the activity gets
    active, I want to resume decompressing
    from the last point.

    That will be extremely difficult, if not impossible.

    I was thinking using a service, but I
    also want to interact with UI, such as
    showing a progress or whatever.

    This is a fine plan. Just have the activity register a listener with the service, and the service calls that listener for “a progress or whatever”.

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

Sidebar

Related Questions

I have a c++ program which performs one function. It loads a large data-file
I have a large raw data file (up to 1GB) which contains raw samples
I have several large MyISAM tables (data file around 1.5 GB) which I need
I have a large XML data file (>160M) to process, and it seems like
I've found a sample to download a large data file at the following link,
I have large data files stored in S3 that I need to analyze. Each
I have large data files of values on a 2D grid. They are organized
I have some large tables (millions of rows). I constantly receive files containing new
I have a silverlight 2 beta 2 application that accesses a WCF web service.

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.