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?
Asked
Active
Viewed 3,851 times
3 Answers
12
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);

jakebasile
- 8,084
- 3
- 28
- 34
-
Any example how to use this please? :) – Maurice Jul 13 '11 at 03:48
-
Nevermind got it here. http://stackoverflow.com/questions/5107823/force-scan-files-after-taking-photo – Maurice Jul 13 '11 at 03:56
-
What is `MediaScanner` for God sake?! , it should be `MediaScannerConnection` instead ! – Yahya Apr 06 '18 at 08:33
-
It should be something like this: `MediaScannerConnection.scanFile(getContext(), new String[]{file.getPath()}, null, null);` – Yahya Apr 06 '18 at 08:35
2
Try this answer. Working for me
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(finalFile)));

Ranjithkumar
- 16,071
- 12
- 120
- 159