保存到SD卡Android的图片没有显示在库图片、SD、Android

2023-09-05 00:52:26 作者:菇涼不要狂@

目前我有一个程序,它的照片,并将其保存在SD卡的顶层JPG格式,但它没有出现在画廊。有什么是我必须做的做到这一点?

Currently I have a program that takes pictures and saves them as a jpg on the top level of the sdcard, but its not appearing in the Gallery. Is there something I must do to make it happen?

推荐答案

您需要致电MediaScanner ,以便它知道你的文件存在:

You need to call the MediaScanner so that it knows your file exists:

File file; // = your file
String mimetype; // = your file's mimetype. MimeTypeMap may be useful.
MediaScanner.scanFile(getApplicationContext(), new String[]{file.getPath()}, new String[]{mimetype}, null);