SD卡的内容存在,但无法看到它们 [英] SDCard content exist but cant see them

查看:209
本文介绍了SD卡的内容存在,但无法看到它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很奇怪的问题,我的三星Nexus采用Android 4.0.2。我写这基本上建立档案,每次用户presses一个按钮,一个简单的程序。我的计划是伟大的工作在其他设备上,其中作为Galaxy Nexus的Windows / Mac的不能看在SD卡上的那些文件,但是当我做亚行的shell我看到在SD卡中的所有文件。

I am having very Strange problem with my Samsung Nexus with Android 4.0.2. I wrote a simple program which basically create file each time user presses a button. My program is working great on other devices where as on Galaxy Nexus Windows/Mac can not see those files on SD card, but when i do adb shell i see all files on SD Card.

我重新测试这在其他的Nexus拥有的Andr​​oid 4.0.4,但还是同样的结果。

I retest this on another Nexus which has Android 4.0.4 but still same result.

可能是什么原因呢?

推荐答案

您可能通过 MediaScannerConnection 需要的索引文件。

You probably need to index your files via MediaScannerConnection. Quoting myself from a blog post from last year:

...的MTP内容不根据外部存储的文字内容。相反,MTP内容基于哪些文件已扫描MediaScannerConnection。如果你写一个文件到外部存储,直至及除非该文件被扫描MediaScannerConnection,它不会看到用户通过MTP。

...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.

外部存储扫描上重新启动,并可能定期。用户可以通过像SDRescan公用事业手动强制扫描。然而,最好的答案就是你使用SCANFILE()上MediaScannerConnection更新媒体数据库您关闭文件之后。这将使你的文件立即提供给用户。

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.

这篇关于SD卡的内容存在,但无法看到它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆