tags:

views:

69

answers:

2

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 Trying Code 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();
A: 

There are lot of examples available for this

Check this post

http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview

and link

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

Rahul
A: 

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