how to save image to sdcard folder from array in android

public void SaveImage(){
BitmapDrawable btmpDr = (BitmapDrawable) mCollageImageView.getDrawable();
Bitmap bmp = btmpDr.getBitmap();
File direct = new File(Environment.getExternalStorageDirectory() + "/collage app image");

if (!direct.exists()) {
    File wallpaperDirectory = new File("/sdcard/collage app image/");
    wallpaperDirectory.mkdirs();
}
File f = null;
f = new File(direct, UUID.randomUUID().toString() + ".png");
if (f.exists()) {
    f.delete();
}
try {
    FileOutputStream out = new FileOutputStream(f);
    bmp.compress(Bitmap.CompressFormat.JPEG, 100, out);
    out.flush();
    out.close();
    Toast.makeText(getContext(), "Image is saved successfully.", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
    e.printStackTrace();
}
}

Comments

Popular posts from this blog

how to fetch blob image gallery in php html sql

how to save image to pdf in android

How to create album view with fancybox slider view in html php complete code