Android API 29最新把文件转存到外部公共图片相册库
Android API 29最新把文件转存到外部公共图片相册库
private boolean saveImageAlbum(File file) throws Exception {
Bitmap bmp = BitmapFactory.decodeFile(file.getAbsolutePath());
ContentValues cv = new ContentValues();
cv.put(MediaStore.Images.Media.DISPLAY_NAME, file.getName());
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv);
OutputStream outputStream = getContentResolver().openOutputStream(uri, "rw");
boolean done = bmp.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
return done;
}
还没有评论,来说两句吧...