Code example for ByteArrayOutputStream

Methods: closetoByteArrayflush

0
    static void writeBitmap(ContentValues values, String name, Bitmap bitmap) {
        if (bitmap != null) {
            // Try go guesstimate how much space the icon will take when serialized 
            // to avoid unnecessary allocations/copies during the write. 
            int size = bitmap.getWidth() * bitmap.getHeight() * 2;
            ByteArrayOutputStream out = new ByteArrayOutputStream(size);
            try { 
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                out.flush();
                out.close();
 
                values.put(name, out.toByteArray());
            } catch (IOException e) {
                // Ignore 
            } 
        } 
    } 
 
    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Connect your IDE to all the code out there  Get Codota for Java