private static final String FILENAME = "abc.txt";
private static final String DIR = "eddata";
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File file = new File(Environment.getExternalStorageDirectory().toString()+File.separator+DIR+File.separator+FILENAME);
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
...........文件写入操作 使用处理流PrintStream
}
需要在AndroidManifest.xml文件中声明如下权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />