//sdcard是否安裝
boolean mExternalStorageAvailable = false;
//sdcar是否可以寫入
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if(Environment.MEDIA_MOUNTED.equals(state)) {
//可以讀取和寫入sdcar
// We can read and write the media
mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
//只能讀不能寫
// We can only read the media
mExternalStorageAvailable = true;
mExternalStorageWriteable = false;
} else {
//其他原因
// Something else is wrong. It may be one of many other states, but all we need
// to know is we can neither read nor write
mExternalStorageAvailable = mExternalStorageWriteable = false;
}
引用來源
沒有留言:
張貼留言