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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:54:25+00:00 2026-05-24T17:54:25+00:00

i want to store images in \mnt\sdcard package com.Downld_file_frm_net; import java.io.BufferedInputStream; import java.io.File; import

  • 0

i want to store images in \mnt\sdcard

    package com.Downld_file_frm_net;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import org.apache.http.util.ByteArrayBuffer;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class Downld_file_frm_net extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //http://203.109.115.55/MRESC/images/150.jpg
        DownloadFromUrl("http://www.garyolsen.com/goclarke/digitalphotography/2006-2/NLechPortfolio/images/Fire%20Flower_jpg.jpg","Fire%20Flower_jpg.jpg");

    }

    public void DownloadFromUrl(String DownloadUrl, String fileName) {

           try {
                   File root = android.os.Environment.getExternalStorageDirectory();               

                   File dir = new File (root.getAbsolutePath() + "mnt/sdcard/");
                   if(dir.exists()==false) {
                        dir.mkdirs();
                   }

                   URL url = new URL(DownloadUrl); //you can write here any link
                   File file = new File(dir, fileName);

                   long startTime = System.currentTimeMillis();
                   Log.d("DownloadManager", "download begining");
                   Log.d("DownloadManager", "download url:" + url);
                   Log.d("DownloadManager", "downloaded file name:" + fileName);

                   /* Open a connection to that URL. */
                   URLConnection ucon = url.openConnection();

                   /*
                    * Define InputStreams to read from the URLConnection.
                    */
                   InputStream is = ucon.getInputStream();
                   BufferedInputStream bis = new BufferedInputStream(is);

                   /*
                    * Read bytes to the Buffer until there is nothing more to read(-1).
                    */
                   ByteArrayBuffer baf = new ByteArrayBuffer(5000);
                   int current = 0;
                   while ((current = bis.read()) != -1) {
                      baf.append((byte) current);
                   }


                   /* Convert the Bytes read to a String. */
                   FileOutputStream fos = new FileOutputStream(file);
                   fos.write(baf.toByteArray());
                   fos.flush();
                   fos.close();
                   Log.d("DownloadManager", "download ready in" + ((System.currentTimeMillis() - startTime) / 1000) + " sec");

           } catch (IOException e) {
               Log.d("DownloadManager", "Error: " + e);
           }

        }
}

permission ::

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

logcate ::

   08-11 11:28:37.673: DEBUG/AndroidRuntime(7606): Shutting down VM
08-11 11:28:37.673: DEBUG/dalvikvm(7606): Debugger has detached; object registry had 1 entries
08-11 11:28:38.223: DEBUG/DownloadManager(7631): download begining
08-11 11:28:38.223: DEBUG/DownloadManager(7631): download url:http://www.garyolsen.com/goclarke/digitalphotography/2006-2/NLechPortfolio/images/Fire%20Flower_jpg.jpg
08-11 11:28:38.233: DEBUG/DownloadManager(7631): downloaded file name:Fire%20Flower_jpg.jpg
08-11 11:28:39.382: INFO/global(7631): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
08-11 11:28:42.193: DEBUG/dalvikvm(7631): GC_FOR_MALLOC freed 1181 objects / 146296 bytes in 64ms
08-11 11:28:45.552: DEBUG/DownloadManager(7631): Error: java.io.FileNotFoundException: /mnt/sdcardmnt/sdcard/Fire%20Flower_jpg.jpg (No such file or directory)
08-11 11:28:45.672: INFO/ActivityManager(70): Displayed activity com.Downld_file_frm_net/.Downld_file_frm_net: 8036 ms (total 8036 ms)
08-11 11:28:50.802: DEBUG/dalvikvm(178): GC_EXPLICIT freed 115 objects / 5224 bytes in 107ms
08-11 11:28:55.854: DEBUG/dalvikvm(190): GC_EXPLICIT freed 733 objects / 40232 bytes in 119ms
  • 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-24T17:54:26+00:00Added an answer on May 24, 2026 at 5:54 pm

    try this code

    package com.Downld_file_frm_net;
    
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;
    
    import org.apache.http.util.ByteArrayBuffer;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    
    public class Downld_file_frm_net extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            //http://203.109.115.55/MRESC/images/150.jpg
            DownloadFromUrl("http://www.garyolsen.com/goclarke/digitalphotography/2006-2/NLechPortfolio/images/Fire%20Flower_jpg.jpg","Fire%20Flower_jpg.jpg");
    
        }
    
        public void DownloadFromUrl(String DownloadUrl, String fileName) {
    
               try {
                       File dir = new File("/sdcard/yourDir");               
    
    
                       if(dir.exists()==false) {
                            dir.mkdirs();
                       }
    
                       URL url = new URL(DownloadUrl); //you can write here any link
                       File file = new File(dir, fileName);
    
                       long startTime = System.currentTimeMillis();
                       Log.d("DownloadManager", "download begining");
                       Log.d("DownloadManager", "download url:" + url);
                       Log.d("DownloadManager", "downloaded file name:" + fileName);
    
                       /* Open a connection to that URL. */
                       URLConnection ucon = url.openConnection();
    
                       /*
                        * Define InputStreams to read from the URLConnection.
                        */
                       InputStream is = ucon.getInputStream();
                       BufferedInputStream bis = new BufferedInputStream(is);
    
                       /*
                        * Read bytes to the Buffer until there is nothing more to read(-1).
                        */
                       ByteArrayBuffer baf = new ByteArrayBuffer(5000);
                       int current = 0;
                       while ((current = bis.read()) != -1) {
                          baf.append((byte) current);
                       }
    
    
                       /* Convert the Bytes read to a String. */
                       FileOutputStream fos = new FileOutputStream(file);
                       fos.write(baf.toByteArray());
                       fos.flush();
                       fos.close();
                       Log.d("DownloadManager", "download ready in" + ((System.currentTimeMillis() - startTime) / 1000) + " sec");
    
               } catch (IOException e) {
                   Log.d("DownloadManager", "Error: " + e);
               }
    
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store images in a .dll file and use them for my
currently i am using acts_as_attachment and also using Capistrano. I want to store images
I want to store the images related to a each person's profile in the
I want to store images in Db4o using Blobs. How can I store them
I want to store .flv files in the database and not in the file
i am fetching around 1500 image url and want to store these images in
I have about 60 images I want to store in Core Data, 30 of
I want to store images from the flex application to a asp net web
I need to store images(I cropped them in a for loop,after every crop,I want
Hai! I am new to android. I want to store the images into the

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.