This article for everyone in detail under the Android Read assets picture resources to save the specific implementation of SD card, interested members can refer to Ha, I hope to help you have
copy code code 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.decode ByteArray (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, fout);
FOuT.flush ();
Fout.close ();
return true;
} catch (Exception e) {
//Todo:handle Exception
E.printstacktrace ();
}
return false;
}
}