//得到SD卡的状态
String state = Environment.getExternalStorageState();
//如果SD卡是存在的, 就把文件写到sd卡中
if(state.equals(Environment.MEDIA_MOUNTED)){
file = new File(Environment.getExternalStorageDirectory(),"a.txt");
try {
FileOutputStream fos=new FileOutputStream(file);
fos.write("要写入的内容".getBytes());
fos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String state = Environment.getExternalStorageState();
//如果SD卡是存在的, 就把文件写到sd卡中
if(state.equals(Environment.MEDIA_MOUNTED)){
file = new File(Environment.getExternalStorageDirectory(),"a.txt");
try {
FileOutputStream fos=new FileOutputStream(file);
fos.write("要写入的内容".getBytes());
fos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}