Code example for Bitmap

Methods: compressgetHeightgetWidth

            boolean success = false;
            try { 
                // 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() * 4;
                ByteArrayOutputStream out = new ByteArrayOutputStream(size);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                ContentValues values = new ContentValues();
                values.put(PhotoDatabaseHelper.FIELD_APPWIDGET_ID, appWidgetId);
                values.put(PhotoDatabaseHelper.FIELD_PHOTO_BLOB, out.toByteArray());
                SQLiteDatabase db = getWritableDatabase();
                db.insertOrThrow(PhotoDatabaseHelper.TABLE_PHOTOS, null, values);
                success = true;
            } catch (SQLiteException e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE