Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedOutputStream;

import java.io.FileOutputStream;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

import android.os.Environment;

public class Main {
    public static boolean storeBitmapToFile(Bitmap bitmap, String filePath) {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            try {
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
                bitmap.compress(CompressFormat.PNG, 50, bos);
                bos.flush();
                bos.close();
            } catch (Exception e) {
                return false;
            }
            return true;
        }

        return false;
    }
}