我已經檢查了下面的代碼Environment.getExternalStorageDirectory()。canWrite()返回false
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
Log.d("StatusActivity", "sdcard mounted and writable");
}
else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
Log.d("StatusActivity", "sdcard mounted readonly");
}
else {
Log.d("StatusActivity", "sdcard state: " + state);
}
輸出顯示sdcard mounted and writable
但Environment.getExternalStorageDirectory().canWrite()
始終返回false。任何人都可以建議嗎?
在清單文件中添加'<使用權限android:name =「android.permission.WRITE_EXTERNAL_STORAGE」/>確實解決了問題'解決了問題 – misguided