When you save the picture after opening gallery, some will automatically refresh you, some do not, so that the picture saved to the SD card, not in time to see in gallery, encountered this situation is best to refresh themselves.
Full SD card scanning via intent.action_media_mounted:
The code is as follows |
Copy Code |
public void Sdscan () { Sendbroadcast (New Intent (intent.action_media_mounted, Uri.parse ("file://") + environment.getexternalstoragedirectory ())); }
|
To scan a file by Intent.action_media_scanner_scan_file:
The code is as follows |
Copy Code |
public void FileScan (String filePath) { Uri data = Uri.parse ("file://" +filepath); Sendbroadcast (New Intent (Intent.action_media_scanner_scan_file, data)); } |
Note: filepath is the address of the picture in the SD card, when the picture is saved, call the above method; Sendbroadcast is a method of the class context.