Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; public class Main { public static byte[] getFileDataFromBitmap(Context context, Bitmap bitmap) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 0, byteArrayOutputStream); return byteArrayOutputStream.toByteArray(); } }