if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
//返回一个File对象,其路径是sd卡的真实路径
File f = new File(Environment.getExternalStorageDirectory(),"info.txt");
FileOutputStream fos;
try {
fos = new FileOutputStream(f);
//把『username:pwd』写入info.txt中
fos.write("username:pwd".getBytes());
fos.close();
}catch (Exception e){
e.printStackTrace();
}
}
检测sd卡状态,并往sd卡写入文件
最新推荐文章于 2018-01-03 16:49:47 发布