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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:53:21+00:00 2026-06-06T10:53:21+00:00

I want to download image from url and store in sdcard’s folder. If folder

  • 0

I want to download image from url and store in sdcard’s folder.
If folder is not exist make folder and save it.
But its giving following exception:

java.io.FileNotFoundException: /mnt/sdcard (Is a directory)
  • 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-06T10:53:23+00:00Added an answer on June 6, 2026 at 10:53 am

    The message is clear. /mnt/sdcard is a directory not a file. You need to create FileOutputStream that writes to a non-directory path.

    For example:

    //Setting up cache directory to store the image
    File cacheDir=new File(context.getCacheDir(),"cache_folder");
    
    // Check if cache folder exists, otherwise create folder. 
    if(!cacheDir.exists())cacheDir.mkdirs();
    
    // Setting up file to write the image to. 
    File f=new File(cacheDir, "img.png");
    
    // Open InputStream to download the image. 
    InputStream is=new URL(url).openStream();
    
    // Set up OutputStream to write data into image file. 
    OutputStream os = new FileOutputStream(f);
    
    HelperUtil.CopyStream(is, os);
    
    ...
    
    
    
    /**
     * Copy all data from InputStream and write using OutputStream
     * @param is InputStream
     * @param os OutputStream
     */
    public static void CopyStream(InputStream is, OutputStream os)
    {
        final int buffer_size=1024;
        try
        {
            byte[] bytes=new byte[buffer_size];
            for(;;)
            {
              int count=is.read(bytes, 0, buffer_size);
              if(count==-1)
                  break;
              os.write(bytes, 0, count);
            }
        }
        catch(Exception ex){}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to cache an image I download from a URL in the local
I want to Download An image from a remote server. But each time I
I'm trying to download images (.jpg) from web folder using wget. I want to
I am working on blackberry project where i want to download image & save
what I want: Download a webpage from a server > Save content in a
I've been looking for a way to download an image from a URL, preform
I'm using BitmapFactory.decodeStream to load an image from a url in Android. I want
Hail! I want to fetch image from NOT PUBLIC Google Site's page. I'm using
I am displaying image's from web using Image downloading logic from url, I want
I want to download image from the path. This is my code: String urlString

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.