private boolean addBitmapToAlbum(Context context, Bitmap bm) {
String uriStr = MediaStore.Images.Media.insertImage(context.getContentResolver(), bm, "", "");
SwitchLogger.d(LOG_TAG, "local album uriStr = " + uriStr);
if(uriStr == null){
return false;
}
String picPath = getFilePathByContentResolver(PictureDetailActivity.this, Uri.parse(uriStr) );
SwitchLogger.d(LOG_TAG, "begin to add to album, picture path = " + picPath);
if(picPath == null) {
return false;
}
ContentResolver contentResolver = context.getContentResolver();
ContentValues values = new ContentValues(4);
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "p_w_picpath/png");
values.put(Images.Media.ORIENTATION, 0);
values.put(Images.Media.DATA, picPath);
contentResolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
return true;
}
转载于:https://blog.51cto.com/changshizhe/1295241