Android Save Bitmap to Gallery

Save bitmap to Galley / Internal / SDCARD
private String saveToInternalStorage(Bitmap bitmapImage){
        File mypath = new File(Environment.getExternalStoragePublicDirectory("MY_IMAGE"),  "MY_IMAGE" + System.currentTimeMillis() + ".png");
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(mypath);
            bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return mypath.getAbsolutePath();
    }

Komentar