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
Post a Comment