Show Image View from file path? Show Image View from file path? android android

Show Image View from file path?


Labeeb is right about why you need to set image using path if your resources are already laying inside the resource folder ,

This kind of path is needed only when your images are stored in SD-Card .

And try the below code to set Bitmap images from a file stored inside a SD-Card .

File imgFile = new  File("/sdcard/Images/test_image.jpg");if(imgFile.exists()){    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());    ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);    myImage.setImageBitmap(myBitmap);}

And include this permission in the manifest file:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


I think you can use this

Bitmap bmImg = BitmapFactory.decodeFile("path of your img1");imageView.setImageBitmap(bmImg);


You can also use:

    File imgFile = new  File(“filepath”);    if(imgFile.exists())    {        ImageView myImage = new ImageView(this);        myImage.setImageURI(Uri.fromFile(imgFile));    }

This does the bitmap decoding implicit for you.