add Bitmap To Album - Android android.media

Android examples for android.media:Album

Description

add Bitmap To Album

Demo Code

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.graphics.Bitmap;
import android.provider.MediaStore;

public class Main {

  public static boolean addBitmapToAlbum(Context context, Bitmap bm) {
    if (bm == null || context == null) {
      return false;
    }// ww w.  j  a va2s  . co m
    String uriStr = MediaStore.Images.Media.insertImage(context.getContentResolver(), bm, "", "");
    if (uriStr == null) {
      return false;
    }
    String picPath = "yourPath";


    ContentResolver contentResolver = context.getContentResolver();
    ContentValues values = new ContentValues(4);
    values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
    values.put(MediaStore.Images.Media.ORIENTATION, 0);
    values.put(MediaStore.Images.Media.DATA, picPath);
    contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

    return true;
  }


}

Related Tutorials