Skip to content Skip to sidebar Skip to footer

How To Read Image From Internal Memory In Android?

this screen shot of my internal memory storage which i save image already. i want to read image in image view. so how to get path of image or how can i read image from internal mem

Solution 1:

private String readFileFromInternalStorage(){
    ImageViewimageView= (ImageView) findViewById(R.id.image);
    ContextWrappercw=newContextWrapper(context);

    //path to /data/data/yourapp/app_data/dirNameFiledirectory= cw.getDir("dirName", Context.MODE_PRIVATE);          
    File mypath=newFile(directory,"imagename.jpg");

    ImageViewimageView= (ImageView) findViewById(R.id.image);
    imageView.setImageDrawable(Drawable.createFromPath(mypath.toString()));
}

Code isn't tested. Or Try Below!

privatevoidsetImage(String imgPath)
{

    try {
        File f=newFile(imgPath, "imgName.jpg");
        Bitmap b = BitmapFactory.decodeStream(newFileInputStream(f));
        ImageView img=(ImageView)findViewById(R.id.image);
        img.setImageBitmap(b);
    } 
    catch (FileNotFoundException e) 
    {
        e.printStackTrace();
    }

}

Solution 2:

Try like this it will Work ,

ImageViewpicture= (ImageView) findViewById(R.id.imageView1);  

       Stringpic= result.getString(YourImagepathname);//get path of your imageBitmapyourSelectedImage1= BitmapFactory.decodeFile(pic);
       picture.setImageBitmap(yourSelectedImage1);

Post a Comment for "How To Read Image From Internal Memory In Android?"