0

In my Application, i need to download the image from server and save it in SDcard. I am using Volley library to download the image from server. Issue in my Application is when i am downloading the image from server it is 30kb and after downloaded checking the size of that image in SDcard was 200kb.

This is my SavedSDcard() which is used to save the image in SDcard and returning the ImagePath.

public String SavedInSDCard(Bitmap bitmap_in, String id) {

    File dir = new File(ApplicationController.getInstance()
            .getExternalFilesDir("MyApplicationName") + "/Cache");
    // Create the storage directory if it does not exist
    if (!dir.exists()) {
        dir.mkdirs();
    }

    File file = new File(dir, id);
    try {
        FileOutputStream out = new FileOutputStream(file);
        bitmap_in.compress(Bitmap.CompressFormat.JPEG, 100, out);
        out.flush();
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    String imgPath = dir + "/" + id;
    return imgPath;
}
Ashok
  • 839
  • 10
  • 21

2 Answers2

2
bitmap2.compress(Bitmap.CompressFormat.JPEG, 100, out);

Remove above line from the code.

Piyush
  • 18,895
  • 5
  • 32
  • 63
0

First

bitmap2.compress(Bitmap.CompressFormat.JPEG, 100, out);

You can decrease the value of 100 for reducing the Image Size. put 70 or 80 instead of 100.

Second

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Akarsh M
  • 1,629
  • 2
  • 24
  • 47