I want to display external storage image like:
"storage/sdcard0/image.jpg"
in my android application.
can any one guide me how to achieve this?
I want to display external storage image like:
"storage/sdcard0/image.jpg"
in my android application.
can any one guide me how to achieve this?
If your image is in the root folder of sdcard then access it through
Bitmap bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().toString + File.separator + "yourimage.jpg");
webImage.setImageBitmap(bmp);
this is the right way to do this:
Bitmap myBitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + File.separator + "image.jpg");
myImageView.setImageBitmap(myBitmap);
but is necessary add the permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
or require this permission manually for OS 6.0+ :
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
int permissionCheck = ContextCompat.checkSelfPermission(
this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 225);
}
}
Try this function:
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+File.separator+"image.png");
Set this bitmap to imageview:
imageView.setImageBitmap(bitmap);