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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:49:53+00:00 2026-06-13T05:49:53+00:00

This code works when downloading from an apache server no problem. but when testing

  • 0

This code works when downloading from an apache server no problem. but when testing on using iis 7.5 currenlty installed on win7. it doesn’t seem to work at getInputStream(); although the full address to the file is being shown when debuging and pasting that into the browser starts the download of the apk

Reading this site and the internet have added MIME TYPE .apk application/vnd.android.package-archive

try {

                        URL url = new URL(prefs.getString("server_address", null) + "/updates/filename.apk");
                        HttpURLConnection c = (HttpURLConnection) url.openConnection();
                        c.setRequestMethod("GET");
                        c.setDoOutput(true);
                        c.connect();

                        String PATH = Environment.getExternalStorageDirectory() + "/download/";
                        File file = new File(PATH);
                        file.mkdirs();
                        File outputFile = new File(file, "filename.apk");
                        FileOutputStream fos = new FileOutputStream(outputFile);

                        InputStream is = c.getInputStream();

                        byte[] buffer = new byte[1024];
                        int len1 = 0;
                        while ((len1 = is.read(buffer)) != -1) {
                            fos.write(buffer, 0, len1);
                        }
                        fos.close();
                        is.close();



                        } catch (IOException e) {
                            Toast.makeText(context, "error!", Toast.LENGTH_LONG).show();
                        }
  • 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-13T05:49:54+00:00Added an answer on June 13, 2026 at 5:49 am

    just get rid of this code:

          c.setRequestMethod("GET");
          c.setDoOutput(true);
          c.connect();
    

    first is not necessary, second, c.setDoOutput(true); is changing request method to POST …
    and thats why you’re getting 405 method not allowed …

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

Sidebar

Related Questions

I'm using this code for downloading image from server: public Bitmap getBitmap(String path){ URL
I am using this code from android developer blog for downloading a BMP file
This code works well for displaying separate xml items in my main.xml. But is
This code works fine, but I'll want to handle exception if any thing goes
server: apache http server 2.2 problem: code does not load my text file hello
Boy, is this frustrating... I installed the httplib2 by downloading the .tar.gz package from
I am downloading zip file from web server using Java in my jsf bean.
I'm downloading files from a HTTPS website. I've narrowed the problem down to this:
This code works well: UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame]; [pickerView addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr

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.