SoFunction
Updated on 2025-03-11

Android read Assets image resources to save to SD card instance


public class ReadBitmap {
public void readByte(Context c, String name, int indexInt) {
byte[] b = null;
int[] intArrat = ().getIntArray(indexInt);
try {
AssetManager am = null;
am = ();
InputStream is = (name);
for (int i = 0; i < ; i++) {
b = new byte[intArrat[i]];
// Read data
(b);
saveMyBitmap(Bytes2Bimap(b), +name+i+".jpg");
}
();
} catch (IOException e) {
();
}
}
public static Bitmap Bytes2Bimap(byte[] b) {
if ( != 0) {
return (b, 0, );
} else {
return null;
}
}

public static boolean saveMyBitmap(Bitmap bmp, String path) {
File f = new File(path);
try {
();
FileOutputStream fOut = new FileOutputStream(f);
(, 100, fOut);
();
();
return true;
} catch (Exception e) {
// TODO: handle exception
();
}
return false;
}
}