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);
If you only want to search in a specific folder - use a specific Uri. File myFile = new File("/scard/myfolder"); Uri myUri = Uri. fromFile(myFile);
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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With