Use Activit's openFileOutput () method to save the file, which is placed inside the mobile phone;
Note: create an image file for the SDCard in the simulator. You can create an image file in the simulator or install the tools directory in the android SDK installation path in the Dos window. Run the following command: mksdcard 2048 m d: \ AndroidTool \ sdcard. img
To access SDCard in a program, you must:Permission:
Permission to create and delete files in SDCard
<Uses-permission android: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS"/>
Write Data permission in SDCard
<Uses-permission android: name = "android. permission. WRITE_EXTERNAL_STORAGE"/>
Public void saveToSDCard (String filename, String filecontent) throws IOException {
File file = new File (Environment. getExternalStorageDirectory (), filename); // get the path of the SDCard
FileOutputStream outStream = new FileOutputStream (file );
OutStream. write (filecontent. getBytes ());
OutStream. close ();
}
//Determine whether the SD card exists and can be read and written
// If (Environment. getExternalStorageState (). equals (Environment. MEDIA_MOUNTED )){
// Fs. saveToSDCard (filenamestr, filecontentstr );
// Toast. makeText (getApplicationContext (), R. string. success, 1). show ();
//} Else {
// Toast. makeText (getApplicationContext (), R. string. sdcarderror, 1). show ();
//}