gpt4 book ai didi

android - SD卡内容存在但看不到

转载 作者:太空狗 更新时间:2023-10-29 15:39:13 31 4
gpt4 key购买 nike

我的 Samsung Nexus Android 4.0.2 出现了非常奇怪的问题。我写了一个简单的程序,基本上每次用户按下按钮时都会创建文件。我的程序在其他设备上运行良好,因为在 Galaxy Nexus Windows/Mac 上无法看到 SD 卡上的这些文件,但是当我执行 adb shell 时,我看到了 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.

关于android - SD卡内容存在但看不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10643476/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com