我的三星Nexus与 Android 4.0.2的问题非常严重.我写了一个简单的程序,基本上每次用户按下按钮时都会创建文件.我的程序在其他设备上工作得很好,因为Galaxy Nexus Windows / Mac无法在SD卡上看到
我在另一个拥有Android 4.0.4的Nexus上重新测试了这个,但结果仍然相同.
可能是什么原因?
您可能需要通过MediaScannerConnection索引文件.引用自己 from a blog post from last year:…the MTP contents are not based on the literal contents of external storage. Instead, MTP contents are based on what files have been scanned by MediaScannerConnection. If you write a file to external storage, until and unless that file is scanned by MediaScannerConnection, it will not be visible to users over MTP.
External storage is scanned on a reboot and possibly on a periodic basis. Users can manually force a scan via utilities like SDRescan. However, the best answer is for you to use scanFile() on MediaScannerConnection to update the media database after you close your file. This will make your file immediately available to the user.