我在 Manifest 文件中添加<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
。當我運行下面的代碼時,提示"SDcard mounted RO"
。哪裡出錯呢?
if(!extState.equals(Environment.MEDIA_MOUNTED)) {
Log.d(Tag.getTag(this),
("SDcard not mounted"));
}
else if (!extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
Log.d(Tag.getTag(this),
("SDcard mounted RO"));
}
else {
Log.d(Tag.getTag(this),
("SDcard mounted RW"));
}
!extState.equals(Environment.MEDIA_MOUNTED_READ_ONLY)
不為RO時提示RO。錯在這裡,去掉“!”