Start the Mediascanner service, scan the media files, and launch the Mediascanner service by sending the following intent.
Scan the specified file
public void Scanfile (Context ctx, String filePath) {Intent scanintent = new Intent (intent.action_media_scanner_scan_file); Scanintent.setdata (Uri.fromfile ( new File (FilePath)); Ctx.sendbroadcast (scanintent); }
scan specified directory
public static final String Action_ Media_scanner_scan_dir = " < span> public void Scandirasync (Context ctx, String dir) {Intent scanintent = new Intent (Action_media_scanner_scan_dir); Scanintent.setdata (Uri.fromfile ( new File (dir)); Ctx.sendbroadcast (scanintent); }
scan sallery
Public void Sdscan () { sendbroadcast(new Intent (intent.action_media_mounted, Uri.parse (" file://" + environment.getexternalstoragedirectory ()))); }
I'm the dividing line of the king of the land Tiger.
Android--File scanning