判断sd是否存在

1.
private final BroadcastReceiver broadcastRec = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.MEDIA_MOUNTED")) { //SD 卡已经成功挂载
//有SD 卡
} else if (intent.getAction().equals("android.intent.action.MEDIA_REMOVED")
||
intent.getAction().equals("android.intent.action.ACTION_MEDIA_UNMOUNTED")
||
intent.getAction().equals("android.intent.action.ACTION_MEDIA_BAD_REMOVAL")) {//各种未挂载状态
//无SD 卡
} } };
2.
File f = new File("/sdcard/");
f.exists();

你可能感兴趣的:(android,F#)