Download image from SD card using Glide

I have tried and searched for an answer in the last 5 hours. I save the image from google plus to a local folder and using the Glide library to upload the image to the image.

The uri file is the file: ///storage/emulated/0/MyApp/ProfilePics/profile_user1.jpg

I use the code below to upload an image using a slide:

Glide.with(ProfileActivity.this).load(Uri.fromFile(new File(sharedPrefMan.getImageUrl()))).placeholder(R.drawable.placeholder_profile).into(imgProfilePic); 

where sharedPrefMan.getImageUrl () returns / storage / emulated / 0 / MyApp / ProfilePics / profile_user1.jpg

The image is present in this place.

+5
source share
3 answers

If you have an original image path than you should convert to a URI and display an image like this

  String fileName = "1.jpg"; String completePath = Environment.getExternalStorageDirectory() + "/" + fileName; File file = new File(completePath); Uri imageUri = Uri.fromFile(file); Glide.with(this) .load(imageUri) .into(imgView); 

It looks like you have a URI than you need to put in place of a URI

  Glide.with(this) .load(Uri) .into(imgView); 
+13
source

You need to pass uri image as below:

  Glide.with(this) .load(Uri.parse("file:///sdcard/img.png")) .override(612, 816) .into(imageView); 
+3
source

Just use the line below: -

 Glide.with(context).load(uri).transform(new Transform()).into(view) 

And to get uri use the code below: -

  Uri.fromFile(new File(Yourpath)); 
0
source

Source: https://habr.com/ru/post/1239088/


All Articles