"avatar": { "id": "585cda2047c3b5000d24e8a9", "path": "/uploads/avatars/584fcd8d2880960011927a88/0062521347", "color": "#595959" } 

I need to convert the path to a jpg link, but I do not know how to do it.

What is the best way to do this with an ImageView ?

  • one
    What is this jpg link? - pavlofff
  • Doesn't that work? String jpgFileName = "/ uploads / avatars / 584fcd8d2880960011927a88 / 0062521347" + ".jpg"; - Andrew Grow

1 answer 1

In general, it is not necessary to have an extension to display a picture.

 File imgFile = new File("/uploads/avatars/584fcd8d2880960011927a88/0062521347"); if(imgFile.exists()){ Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); ImageView myImage = (ImageView) findViewById(R.id.imageViewTest); myImage.setImageBitmap(myBitmap); } 

and do not forget to take permishen (and for Android above 6 there is also dynamic permishen)

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />