This article describes how to save the image resources of android Assets to the SD card. If you are interested, refer to the following:Copy codeThe Code is as follows:
Public class ReadBitmap {
Public void readByte (Context c, String name, int indexInt ){
Byte [] B = null;
Int [] intArrat = c. getResources (). getIntArray (indexInt );
Try {
AssetManager am = null;
Am = c. getAssets ();
InputStream is = am. open (name );
For (int I = 0; I <intArrat. length; I ++ ){
B = new byte [intArrat [I];
// Read data
Is. read (B );
SaveMyBitmap (Bytes2Bimap (B), MainActivity. DIR + name + I + ". jpg ");
}
Is. close ();
} Catch (IOException e ){
E. printStackTrace ();
}
}
Public static Bitmap Bytes2Bimap (byte [] B ){
If (B. length! = 0 ){
Return BitmapFactory. decodeByteArray (B, 0, B. length );
} Else {
Return null;
}
}
Public static boolean saveMyBitmap (Bitmap bmp, String path ){
File f = new File (path );
Try {
F. createNewFile ();
FileOutputStream fOut = new FileOutputStream (f );
Bmp. compress (Bitmap. CompressFormat. JPEG, 100, fOut );
FOut. flush ();
FOut. close ();
Return true;
} Catch (Exception e ){
// TODO: handle exception
E. printStackTrace ();
}
Return false;
}
}