Reputation: 3095
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 memory?
please help me..
i tried some code but its not working:-
FileInputStream fis;
String filePath = activity.getFilesDir().getPath();
String path = data.get(position).get("product_image");
fis = openFileInput(filePath+"/broccolicasserole.jpg");
Bitmap bitmapA = BitmapFactory.decodeStream(fis);
producticon.setImageBitmap(bitmapA);
image name is get from database like :-data.get(position).get("product_image");
also try this code also:-
> String filePath = activity.getFilesDir().getPath();
File filePath1 = imageLoader.DisplayImage(filePath+data.get(position).get("product_image"), producticon);
Upvotes: 6
Views: 32722
Reputation: 10549
private String readFileFromInternalStorage(){
ImageView imageView = (ImageView) findViewById(R.id.image);
ContextWrapper cw = new ContextWrapper(context);
//path to /data/data/yourapp/app_data/dirName
File directory = cw.getDir("dirName", Context.MODE_PRIVATE);
File mypath=new File(directory,"imagename.jpg");
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.setImageDrawable(Drawable.createFromPath(mypath.toString()));
}
Code isn't tested. Or Try Below!
private void setImage(String imgPath)
{
try {
File f=new File(imgPath, "imgName.jpg");
Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f));
ImageView img=(ImageView)findViewById(R.id.image);
img.setImageBitmap(b);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
Upvotes: 7
Reputation: 433
Try like this it will Work ,
ImageView picture = (ImageView) findViewById(R.id.imageView1);
String pic = result.getString(YourImagepathname);//get path of your image
Bitmap yourSelectedImage1 = BitmapFactory.decodeFile(pic);
picture.setImageBitmap(yourSelectedImage1);
Upvotes: 1