保存文件到sdcard
File file = new File(Environment.getExternalStorageDirectory()+"/pwd.txt");
FileOutputStream fos = new FileOutputStream(file);
String text = username+":"+pwd;
fos.write(text.getBytes());
fos.close();
注意:
1.Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()),判断sdcard是否是可用状态
2.sdcard的路径不能硬编码,用Environment.getExternalStorageDirectory()替换
3.在AndroidManifest.xml文件中添加<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
浙公网安备 33010602011771号