有没有办法判断sdcard是否已安装而未安装?

cot*_*aws 3 android sd-card

使用api逻辑,您可以检测SD卡是否可用于读取或写入,但它不会告诉您它为何不可写.

我想知道用户是否还有sd卡vs如果它刚刚安装.

这可能吗?

Sté*_*ane 7

例如:

String state = Environment.getExternalStorageState();

if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {

}
Run Code Online (Sandbox Code Playgroud)

查看可能的常量:http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState%28%29


Har*_*der 6

public static boolean isSdPresent() {

return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

}
Run Code Online (Sandbox Code Playgroud)