set Image By Path - Android Graphics

Android examples for Graphics:Image File

Description

set Image By Path

Demo Code


//package com.java2s;

import android.graphics.*;
import android.util.Log;
import android.widget.ImageView;
import java.io.File;

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

    public static void setImageByPath(String filePath,
            ImageView profilePicImageView) {
        try {//from   www.  j  a  va2  s . co m
            File imgFile = new File(filePath);
            if (imgFile.exists()) {
                Bitmap myBitmap = BitmapFactory.decodeFile(imgFile
                        .getAbsolutePath());
                profilePicImageView.setImageBitmap(myBitmap);
            }
        } catch (Exception e) {
            Log.e(TAG, "error - " + e.getMessage());
        }
    }
}

Related Tutorials