Android sd card cannot immediately display the file to be written after the file is written. Solution: Android sd
Every time a file is written to the SD card through an output stream, the file is connected to the computer, and a mobile disk is simulated using MTP. Opening the disk does not have such a file, and you can view it through adb, the cause is that the MTP database is not updated after each write, because the price required to update the MTP database is large, so it is only restarted, mounting and sending Intent messages manually. Therefore, you need to manually send Intent broadcasts after saving the files to start updating the MTP database.
/*** Start to scan the files in mtp. After saving the files to the SD card, they cannot be displayed. Therefore, the scan mechanism is triggered to connect the mobile phone to the computer, you can read the file * @ param fName, the complete 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 ));