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

  • Home
  • SEARCH
  • 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 8228853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:36:09+00:00 2026-06-07T16:36:09+00:00

Possible Duplicate: How to write files to assets folder or raw folder in android?

  • 0

Possible Duplicate:
How to write files to assets folder or raw folder in android?

How can i store a image in asset/subfolder in android? is there any maximum limit of asset folder size?
actully i am getting a bunch of image from web and trying to download all image in a subfolder in asset ? is it possible and how?
actully my code is as follows, it save the image in sdcard :-

String filepath=null;
      try {
       //set the download URL, a url that points to a file on the internet
       //this is the file to be downloaded
       URL url = new URL(Url);
       //create the new connection
       HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

       //set up some things on the connection
       urlConnection.setRequestMethod("GET");
       urlConnection.setDoOutput(true); 
        //and connect!
       urlConnection.connect();
       //set the path where we want to save the file
       //in this case, going to save it on the root directory of the
       //sd card.
     File SDCardRoot = Environment.getExternalStorageDirectory();
       //create a new file, specifying the path, and the filename
       //which we want to save the file as.

       String filename= "downloadedFile.png";   // you can download to any type of file ex:.jpeg (image) ,.txt(text file),.mp3 (audio file)
       Log.i("Local filename:",""+filename);
       file = new File(SDCardRoot,filename);
       if(file.createNewFile())
       {
        file.createNewFile();
       }

       //this will be used to write the downloaded data into the file we created
       FileOutputStream fileOutput = new FileOutputStream(file);

       //this will be used in reading the data from the internet
       InputStream inputStream = urlConnection.getInputStream();

       //this is the total size of the file
       int totalSize = urlConnection.getContentLength();
       //variable to store total downloaded bytes
       int downloadedSize = 0;

       //create a buffer...
       byte[] buffer = new byte[1024];
       int bufferLength = 0; //used to store a temporary size of the buffer

       //now, read through the input buffer and write the contents to the file
       while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
        //add the data in the buffer to the file in the file output stream (the file on the sd card
        fileOutput.write(buffer, 0, bufferLength);
        //add up the size so we know how much is downloaded
        downloadedSize += bufferLength;
        //this is where you would do something to report the prgress, like this maybe
        Log.i("Progress:","downloadedSize:"+downloadedSize+"totalSize:"+ totalSize) ;

       }
       //close the output stream when done
       fileOutput.close();
       if(downloadedSize==totalSize)   filepath=file.getPath();

      //catch some possible errors...
      } catch (MalformedURLException e) {
       e.printStackTrace();
      } catch (IOException e) {
       filepath=null;
       e.printStackTrace();
      }
      Log.i("filepath:"," "+filepath) ;

Kindly provide me some solution for that.

  • 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-07T16:36:12+00:00Added an answer on June 7, 2026 at 4:36 pm

    You could not store images in asset folder problematically

    it’s READ-ONLY

    And generally MAX size for asset folder is 1 MB for each file

    You can save image in sdcard.

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

Sidebar

Related Questions

Possible Duplicate: C++ can I reuse fstream to open and write multiple files? why
Possible Duplicate: In C++ why can't I write a for() loop like this: for(
Possible Duplicate: In C++, Why can't I write to a string literal while I
Possible Duplicate: Allow access permission to write in Program Files of Windows 7 okay,
Possible Duplicate: How can I write a Java application that can update itself at
Possible Duplicate: How can I write in nth column of a file in awk?
Possible Duplicate: how to write bat file to process all files include sub directory,
Possible Duplicate: Android HttpClient and HTTPS I want to write app on Android which
Possible Duplicate: Write lines of text to a file in R Is there anyway
Possible Duplicate: using bash: write bit representation of integer to file I need to

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.