Micro SD卡检测
有没有办法在android中检测micro sd卡?我知道环境类提供了外部存储详细信息。但它只提供内置 SD 卡的详细信息。有办法解决吗?
Is there a way to detect a micro sd card in android? I know the Environment class gives external storage details. But it just gives the in built sd card details. Is there a way around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
isExternalStorageEmulated()
找出当前的“外部”存储实际上是真正的外部存储还是只是内部存储的一部分。如果它是真实的,那么您应该获得可移动卡的属性。You can use
isExternalStorageEmulated()
to find out if the current "external" storage is actually a real external storage or just part of the internal storage. If it's real then you should get the properties of the removable card.试试这个:
Try this:
Environment.getExternalStorageState()和Environment.getExternalStorageDirectory()将提供内置SD卡,目前几乎所有Android设备上都存在该卡。
获取“真正的”外部 SD 卡(或 USB 磁盘)的两种方法。
使用 getVolumeList() 函数列出所有可移动存储,记得在访问之前检查挂载状态。
注册android.intent.action.MEDIA_MOUNTED事件,当挂载存储时,会通过挂载的磁盘路径广播此intent。
Environment.getExternalStorageState() and Environment.getExternalStorageDirectory() will provide the built-in SD card, which is almost existing on all currently Android devices now.
Two methods to get the "real" external SD card (or USB disk).
Use the getVolumeList() function to list all removable storages, remember to check the mount state before you access it.
Register android.intent.action.MEDIA_MOUNTED event, when a storage is mounted, will broadcast this intent with the mounted disk path.