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

萝らか妹 提交于 2019-12-17 20:27:03

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!