1. Key code Copy codeThe Code is as follows: // R. drawable. test is an image of the current project.
Bitmap bitmap = BitmapFactory. decodeResource (getResources (),
R. drawable. test );
FileOutputStream fos = null;
Try
{
File file = new File ("/mnt/sdcard/testfile ");
If (! File. exists ())
{
File. mkdir ();
}
Fos = new FileOutputStream ("/mnt/sdcard/testfile/test.jpg ");
// Bitmap. CompressFormat. PNG
Bitmap. compress (Bitmap. CompressFormat. JPEG, 100, fos );
} Catch (FileNotFoundException e)
{
E. printStackTrace ();
}
2. Permissions Copy codeThe Code is as follows: <uses-permission android: name = "android. permission. WRITE_EXTERNAL_STORAGE"/>
<Uses-permission android: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS"/>
Note: A recently written applet is about image scaling. after scaling, you can generate a new image in the notebook, which can only be downloaded from resources.