如何检查物理SD卡是否被移除/安装

时间:2013-09-16 09:51:46

标签: android broadcastreceiver android-sdcard mount

如何检查物理SD卡是否已安装或移除?

<receiver android:name=".MyReceiver" >
<intent-filter>
    <action android:name="android.intent.action.MEDIA_REMOVED" />
    <action android:name="android.intent.action.MEDIA_MOUNTED" />
</intent-filter>

使用此意图过滤器定义广播接收器不会对任何内容做出反应

1 个答案:

答案 0 :(得分:0)

// try this
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
// External SD card not mounted
}else{
// External SD card mounted
}