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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:34:47+00:00 2026-05-26T13:34:47+00:00

I have an interesting problem: My application is designed to send and open up

  • 0

I have an interesting problem: My application is designed to send and open up a zip full of files, and the zip has a special extension (easier for the user). I can zip up the files I need to attach in an e-mail, and I can send them.

When I use the g-mail “view” button and select my app to open the file, it doesn’t unzip them correctly. However, if I use the gmail “download” button, and then open the file through a file explorer, the file unzips correctly.

This is the code I use to download the attachment:

// get attachment
        try {
            attachment = getContentResolver().openInputStream(
                    getIntent().getData());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // Save it
        try {
            File root = Environment.getExternalStorageDirectory();
            path = root.getPath() + "/PSattachment.psz";
            savedFile = new File(path);
            FileOutputStream fos = new FileOutputStream(savedFile, false);
            BufferedOutputStream os = new BufferedOutputStream(fos);
            byte[] buffer = new byte[1024];
            int byteRead = 0;
            while ((byteRead = attachment.read(buffer)) != -1) {
                os.write(buffer, 0, byteRead);
            }
            fos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

Am I doing something wrong? Thanks in advance. (Also, the process of unzipping is the same in both cases [file explorer and view from email], so I’m pretty sure it’s something in here. Also, the file DOES download, and is the right size. It just won’t unzip).

  • 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-26T13:34:48+00:00Added an answer on May 26, 2026 at 1:34 pm

    I found the answer!!! Took a while, but at least it works now:

                try {
                InputStream attachment = getContentResolver()
                        .openInputStream(getIntent().getData());
                savedFile = new File(Environment
                        .getExternalStorageDirectory().getAbsolutePath(),
                        "temp" + System.currentTimeMillis() + ".psz");
                FileOutputStream f = new FileOutputStream(savedFile);
                byte[] buffer = new byte[1024];
                int len1 = 0;
                while ((len1 = attachment.read(buffer)) > 0) {
                    f.write(buffer);
                }
                f.close();
            } catch (Exception e) {
            }
    

    I just used this code to download the attachment and now everything works perfectly =D

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

Sidebar

Related Questions

I have an interesting problem being reported to me from an android application I
I have an interesting problem to solve. One of my clients has me developing
I have interesting problem with my UiimageViews. I have an application (game with 2
found a interesting problem during testing our web application. I have application on localhost
Okay -- we have an interesting problem. Some background: Our main application uses Indy
I have an interesting (but frustraring) problem. I have an application which uses the
Well, this is an interesting problem. I have an ASP.NET MVC3 Intranet application running
I have an interesting problem and would appreciate your thoughts for the best solution.
I have one interesting problem. I must parse mail body (regular expression), get some
I have some interesting problem for an hour.. In my flex project, all width

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.