问题
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 has a sd card vs if it just mounted.
Is this possible?
回答1:
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
回答2:
public static boolean isSdPresent() {
return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
}
来源:https://stackoverflow.com/questions/4878903/is-there-a-way-to-tell-if-the-sdcard-is-mounted-vs-not-installed-at-all