0

Hi I am developing app which downloads the images from the web site and then i am displaying them as slide show. Now I want save the downloaded images into my SD card please help me.

My current attempt is:

File imageFileFolder = new File(Environment
               .getExternalStorageDirectory(), "test");
imageFileFolder.mkdir();
File imageFileName = new File(imageFileFolder, date
               + pBean.getAuthorName());

InputStream fis = pBean.getInputStream();

byte[] data = new byte[fis.available()];
fis.read(data);
FileOutputStream fos = new FileOutputStream(imageFileName);
fos.write(data);
fos.close();
fis.close();
idbrii
  • 10,975
  • 5
  • 66
  • 107
Ramesh Bugatha
  • 1,162
  • 1
  • 11
  • 24

2 Answers2

0

There are lot of examples available for this

Check this post

Lazy load of images in ListView

and link

http://open-pim.com/tmp/LazyList.zip

Community
  • 1
  • 1
DeRagan
  • 22,827
  • 6
  • 41
  • 50
0

In your AndroidManifest.xml you'll need to add the permission to write

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

Then just get get the path to your filename and make sure your directories exist before trying to write the file to the sdcard.

String imageFileName = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/somedirectory/imagename.jpg"
Travis
  • 2,170
  • 1
  • 19
  • 21