①写文件到sd卡中需要获得权限,在AndroidManifest.xml中添加如下权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
②将文件写到sd卡中(java代码):
try {
FileWriter fileWriter = new FileWriter("/sdcard/test1.txt");
fileWriter.write("你好 你好");
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}