Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.util.Log; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static final String TAG = "StickerView"; public static String saveImageToGallery(File file, Bitmap bmp) { if (bmp == null) { Log.e(TAG, "saveImageToGallery: the bitmap is null"); return ""; } try { FileOutputStream fos = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } Log.e(TAG, "saveImageToGallery: the path of bmp is " + file.getAbsolutePath()); return file.getAbsolutePath(); } }