具有 Environment.getExternalStorageDirectory() != /mnt/sdcard/? 的 Android 设备
当然,在我的代码中,我使用Environment.getExternalStorageDirectory()而不是硬连线/mnt/sdcard/。但我刚刚意识到,当我通过数据库转储以交换格式从应用程序导出数据时,文件路径是 /mnt/sdcard/... 这可能解释了我在用户日志中看到的一些奇怪错误。
我将在导入模块中进行适当的更改。但我很好奇 - 有 Android 设备吗? 1.6 有Environment.getExternalStorageDirectory() != /mnt/sdcard/ 吗?
Of course in my code I use Environment.getExternalStorageDirectory() instead of hardwiring /mnt/sdcard/. But I just realized that when I export data from my application via a database dump in an exchange format, file paths are /mnt/sdcard/... This may explain some strange errors that I have seen in the logs from users.
I will make the appropriate changes in the import modules. But I am curious - does any Android devices > 1.6 have Environment.getExternalStorageDirectory() != /mnt/sdcard/ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,对于某些设备,
getExternalStorageDirectory()
将返回内部内存(内部 SD 卡)的本地化。可移动 SD 卡位于下面作为挂载点,通常是getExternalStorageDirectory()+"/sd"
或getExternalStorageDirectory()+"/external_sd"
。不幸的是,对此没有标准,您将不知道您所指向的存储类型。Actually, some for some devices the
getExternalStorageDirectory()
will return localization for internal memory (internal SD card). The removable SD card is located as mount point below, usuallygetExternalStorageDirectory()+"/sd"
orgetExternalStorageDirectory()+"/external_sd"
. Unfortunately, there is no standard for this and you won't know what kind of storage you are pointing at.没有。我还没有看到任何将 SD 卡安装到不同位置的设备。我玩过来自最流行供应商的超过 10 种不同的设备。
话虽如此,您不应该依赖这个事实。特别是如果您有如此简单的方法来获取外部存储的路径。
No. I haven't seen any devices with sdcard mounted to different location. And I've played with more then 10 different devices from most popular vendors.
Having said that, you shouldn't rely on this fact. Especially if you have such an easy way to get path to External storage.
我的一个应用程序的一位用户报告了这一点,他正在使用 Andy 2.2 IIRC,但我不记得他使用的是什么设备。 找到该路径
可以使用我认为我的用户获得的路径是 /sdcard & 。不像我的 HTC 手机那样 /mnt/sdcard。
I had a user of one of my apps report this, he was using Andy 2.2 IIRC but I can't remember what device he was using. The path can be found using
I think the path my user got was /sdcard & not /mnt/sdcard like my HTC phone does.