caipivara
4/18/2015 - 6:50 PM

Android - Save image from Bitmap

Android - Save image from Bitmap

public static String createImageFromBitmap(Bitmap bitmap) {
        String fileName = "bitmappp";//no .png or .jpg needed
        try {
            byte[] bytes = getBytes(bitmap);
            FileOutputStream fo = App.getInstance().openFileOutput(fileName, Context.MODE_PRIVATE);
            fo.write(bytes);
            fo.close();
        } catch (Exception e) {
            Timber.e(e, "can save a file");
            fileName = null;
        }
        return fileName;
    }