为什么执行了代码后没有创建成功,
package com.apress.gerber.file_demo1;
import android.app.Activity;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File file= new File(Environment.getExternalStorageDirectory(),"text.xml");
if(!file.exists())
{
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}else {
Toast.makeText(MainActivity.this,"文件已经存在",1000);
}
}
}