我得到open failed: EISDIR (Is a directory)
。我从中找到的所有解决方案都说 call file.getParentFile().mkdirs()
,但我仍然收到该错误。它打印出来,Good
但也打印出来Directory not created
。
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))
{
Log.e("test", "Good");
}
File f = Environment.getExternalStorageDirectory();
lvlWriter.writeLevel(f);
.
writeLevel(File f)
{
File file = new File(f, "1.txt");
if (!file.getParentFile().mkdirs())
{
Log.e("test", "Directory not created");
}
if (!file.exists())
{
file.createNewFile();
}