Android检测内存卡是否可用

以下代码返回当前手机的内存卡状态:

String state=Environment.getExternalStorageState();
如果state.equals(Environment.MEDIA_MOUNTED)则内存卡存在且可用,否则为内存卡不存在。
 
以下代码返回当前内存卡的目录:
File dir=Environment.getExternalStorageDirectory();
一般内存卡的目录默认为:/mnt/sdcard/
所以dir即为目录:/mnt/sdcard/
原文地址:https://www.cnblogs.com/daocaowu/p/3023799.html