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