File root = Environment.getExternalStorageDirectory();
Log.w("sdcard", "root.canWrite() = " + root.canWrite());
try {
File myFile = new File(root + File.pathSeparator + "mysdfile.txt");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
myOutWriter.append("testing testing 123");
myOutWriter.close();
fOut.close();
} catch (IOException e) {
Log.w("ExternalStorage", "Error writing", e);
}
root.canWrite()返回true,那么这个异常引发:
java.io.IOException: open failed: EROFS (Read-only file system)
清单文件有WRITE_EXTERNAL_STORAGE许可(舱单直接子):
我也试过在使用AVD外壳重新挂载SD卡:
mount -o remount rw /mnt/sdcard
...但无济于事。 AVD还具有“SD卡支持”标志集。不确定在这里做什么,有什么想法?
+0
Android版本? –
+0
模拟器的运行4.0版 –