4.9
代码注释的比较详细.这里重点要说的是初始化数据库的时候,将Drawable转变成byte[]的时候,先讲Drawable转换成Bitmap,然后将Bitmap存入字节数据输出流,从输出流里获取byte[]数组。
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 100, os);
return os.toByteArray();
代码注释的比较详细.这里重点要说的是初始化数据库的时候,将Drawable转变成byte[]的时候,先讲Drawable转换成Bitmap,然后将Bitmap存入字节数据输出流,从输出流里获取byte[]数组。
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 100, os);
return os.toByteArray();