如何在Android中找到SD卡是否可用

时间:2015-11-03 11:09:28

标签: android

我的设备中没有SD卡,但以下代码返回true。

   Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

2 个答案:

答案 0 :(得分:1)

请检查

boolean isSDCardmounted = false;
  isSDCardmounted  = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
    if(isSDCardmounted ){
        //Sd card available
    }else{
       //SD Card not available
    }

答案 1 :(得分:0)

   Boolean isSDAvailable = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

    if(isSDAvailable )
    {
      // yes SD-card is Available
    }
    else
    {
     // Not Find sd card
    }