An Android SD card cannot immediately display the file that was written after it was written to the file solution

Source: Internet
Author: User

each time through the output stream to the SD card to write files, connected to the computer, using MTP to simulate a mobile disk, open the disk but there is no such a file, and the way to see through the ADB, the cause of this phenomenon is that after each write, the MTP database is not updated, Because the update of the MTP database requires a large price ratio, so only in the restart, mount and the user manually send intent, so the file needs to be manually sent intent broadcast, set out the MTP database update.

/**       * To scan the files under MTP, after saving the file to the SD card, can not be displayed, so here trigger a scanning mechanism, so that the phone connected to the computer, you can read the file       * @param fName, the full path name       of the file */ Public   void  FileScan (String fName) {           uri data = URI. Parse ("file:///" +fname);           Sendbroadcast (New  Intent (intent.action_media_scanner_scan_file, data));


An Android SD card cannot immediately display the file that was written after it was written to the file solution

Related Article

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.