Android examples for android.provider:MediaStore
The drawable objects into bitmap and then saved to Gallery, If you need to immediately send a broadcast display at the Gallery
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.drawable.Drawable; import android.media.MediaScannerConnection; import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; import android.util.Log; public class Main{ /**/* w ww .j a v a 2 s.c o m*/ * The drawable objects into bitmap and then saved to Gallery, If you need to immediately send a broadcast display at the Gallery * @param context * @param drawable * @param picName * @return */ public static String saveImageToGallery(Context context, Drawable drawable, String picName) { Bitmap bitmap = BitmapUtils.drawableToBitmap(drawable); String result = MediaStore.Images.Media.insertImage( context.getContentResolver(), bitmap, picName, ""); if (result == null) { return null; } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri .parse("file://" + Environment.getExternalStorageDirectory()))); return ""; } }