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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:39:10+00:00 2026-05-27T22:39:10+00:00

I am trying to save a file from the web to my Android device,

  • 0

I am trying to save a file from the web to my Android device, but I do not know how to do it. The URL address opens a blank page and a popup download box with the file that I want to download so I can choose where to save it.

My problem is that I do not know how to manage that box in order to download the file. It is not like I want to download something that is shown on that page because the page is blank. So I cannot use this code :

         Context context = thisClass.this;
         Drawable image = ImageOperations(context,
          "http://android.okhelp.cz/images/adictionary/ad_4.png"
          ,"image.jpg");
         ImageView imgView;
         imgView = (ImageView)findViewById(R.id.idImageView);
         imgView.setImageDrawable(image);

private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
    try {
        InputStream is = (InputStream) this.fetch(url);
        Drawable d = Drawable.createFromStream(is, "src");
        return d;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

public Object fetch(String address) throws MalformedURLException,IOException {
    URL url = new URL(address);
    Object content = url.getContent();
    return content;
}

I would be grateful if someone could point me where to start looking or gave me a 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-05-27T22:39:11+00:00Added an answer on May 27, 2026 at 10:39 pm

    I solved it!

               File card2= Environment.getExternalStorageDirectory();
               File dir2= new File (card2.getAbsolutePath()+"/MyFiles");
                dir2.mkdirs();
               new DefaultHttpClient().execute(new HttpGet(your_url_here-this_is_a_string)).getEntity().writeTo(
                new FileOutputStream(new File(dir2,your_file_on_sdcard-this_is_string)));
    

    This is also surrounded by try/catch. And remember to insert the protocol before the address or it won’t work!
    Hope it helps!

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

Sidebar

Related Questions

I'm trying to download a file from the web and save it locally, but
I'm trying to parse a file from the web on Android using the DOM
I'm trying to save a dynamic pdf file generated from a web server using
I'm trying to print/save a certain element's HTML from a web-page. I've retrieved the
I'm trying to save a file in a subdirectory in Android 1.5. I can
I am trying to find out how to upload a file from a web
i am trying to save a file from chrome using AjaxSubmit. i got the
I'm trying to save a file to a Sharepoint server using JAX-WS. The web
I am trying to remove a file from path using following code. But my
I'm trying to save a PDF file to SQL Server and I already have

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.