关于Environment.getExternalStorageDirectory()

使用华为手机调试的时候,Environment.getExternalStorageDirectory().getPath()返回的路径是空的.

原因如下:不同的设备上,调用getExternalStorageDirectory()返回值不一样。这个方法返回的是当前设备厂商所认为的“外部存储”,有可能返回外置的SD卡目录(Micro SD Card),也可能返回内置的存储目录(eMMC)。

goole官方文档中的解释: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

你可能感兴趣的:(android)