Mediascanner scan mode

Source: Internet
Author: User

Scanning all I guess it may have some side effects in terms of efficiency

 

Java code
  1. Public void systemscan (){
  2. Sendbroadcast (new intent (intent. action_media_mounted, Uri. parse ("file ://"
  3. + Environment. getexternalstoragedirectory ())));
  4. }

 

 

-Scan a file parameter: Enter the file path.

 

Java code
  1. Public void filescan (string file ){
  2. Uri DATA = URI. parse ("file: //" + file );
  3. Sendbroadcast (new intent (intent. action_media_scanner_scan_file, data ));
  4. }

 

 

-Scan folder parameters: Enter the folder path

 

Java code
  1. Public void filescan (string file ){
  2. Uri DATA = URI. parse ("file: //" + file );
  3. Sendbroadcast (new intent (intent. action_media_scanner_scan_file, data ));
  4. }
  5. Public void folderscan (string path ){
  6. File file = new file (PATH );
  7. If (file. isdirectory ()){
  8. File [] array = file. listfiles ();
  9. For (INT I = 0; I <array. length; I ++ ){
  10. File F = array [I];
  11. If (F. isfile () {// file type
  12. String name = f. getname ();
  13. If (name. Contains (". MP3 ")){
  14. Filescan (F. getabsolutepath ());
  15. }
  16. }
  17. Else {// folder type
  18. Folderscan (F. getabsolutepath ());
  19. }
  20. }
  21. }
  22. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.