Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.util.Log;

public class Main {
    private final static String TAG = "HelperMethods";

    /**
     * get a bitmap by giving a file location
     * @param fileName
     * @return
     */
    public static Bitmap getImgFromLocation(String fileName) {
        File imgFile = new File(fileName);

        Bitmap myBitmap = null;

        //shows an image on the screen
        if (imgFile.exists()) {

            myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
            Log.i(TAG, "file saved");

        } else
            Log.i(TAG, "file not found");

        return myBitmap;
    }
}