Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileOutputStream;

import android.graphics.Bitmap;

public class Main {
    /**
     * Tries to save the picked picture to external storage, this makes it possible to use the same function for
     * retrieving the picture
     *
     * @param pBitmap
     *        The Bitmap we want to save to external storage
     * @param pPhotoPath
     *        The path the photo should be saved to
     */
    public static void savePictureToExternalStorage(Bitmap pBitmap, String pPhotoPath) {
        if (pBitmap == null) {
            return;
        }

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(pPhotoPath);
            pBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (Throwable ignore) {
                // We don't have to do anything
            }
        }
    }
}