要知道SD卡路径Android的最佳途径 [英] Best way to know sd card Path Android

查看:110
本文介绍了要知道SD卡路径Android的最佳途径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道的大多数设备的SD卡路径。我有一些问题的,我实际使用:

  Environment.getExternalStorageDirectory();
 

但有些手机没有回到正确的道路......我不知道为什么。

这是为了检查不同的设备和操作系统版本SD卡路径的最佳方法是什么?

解决方案

目前在Android中没有SD卡路径。

在present时间,Android已经内部存储和外部存储,那就是它。 Environment.getExternalStorageDirectory(); 返回外部存储的根。无论外部存储是:

  • 在板上闪存的同一个分区用于内部存储,或
  • 在板上闪存的一个单独的分区,或
  • 在一些可移动驱动器,像一个microSD卡,或
  • 完全是另一回事

是由设备制造商。

同样,如果设备制造商提供额外的数据存储(例如,一个可移动的卡,除了外部存储作为板上闪存的一部分),现在,这些额外的数据存储是专用设备制造商。该制造商可以选择记录如何使用它们,或者制造商可以整合这些数据存储与别的东西,你可以访问(例如,通过具有多媒体文件通过索引和访问 MediaStore )。

您可以阅读更多关于这外部存储上的文件

因此​​,根据定义, Environment.getExternalStorageDirectory(); 正确的道路重presenting外部存储

I need to know in the most of the devices the sd card path. I have some problems for that I actually use:

 Environment.getExternalStorageDirectory();

But some phones don't return correct path... I don't know why.

Which is the best way to check Sd Card Path for different devices and OS versions?

解决方案

There is no "sd card path" in Android.

At the present time, Android has internal storage and external storage, and that is it. Environment.getExternalStorageDirectory(); returns the root of external storage. Whether external storage is:

  • on the same partition of the on-board flash as is used for internal storage, or
  • on a separate partition of the on-board flash, or
  • is some removable drive, like a microSD card, or
  • is something else entirely

is up to the device manufacturer.

Similarly, if the device manufacturer offers additional data stores (e.g., a removable card in addition to external storage as part of on-board flash), right now, those additional data stores are for the exclusive use of the device manufacturer. That manufacturer may elect to document how you can use them, or the manufacturer may integrate those data stores with something else that you can access (e.g., have multimedia files by indexed and accessible via MediaStore).

You can read more about this in the documentation on external storage.

So, by definition, Environment.getExternalStorageDirectory(); is "the correct path" representing external storage.

这篇关于要知道SD卡路径Android的最佳途径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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