Is there a way to tell if the sdcard is mounted vs not installed at all?

后端 未结 2 654
情话喂你
情话喂你 2020-12-11 09:24

Using the api logic you can detect if the sd card is available for read or write, but it doesn\'t tell you why it is not writable.

I want to know if the user even ha

相关标签:
2条回答
  • 2020-12-11 09:53
    public static boolean isSdPresent() {
    
    return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
    
    }
    
    0 讨论(0)
  • 2020-12-11 09:58

    for example:

    String state = Environment.getExternalStorageState();
    
    if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
    
    }
    

    Check out the possible constants at : http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState%28%29

    0 讨论(0)
提交回复
热议问题