0

I'm coding an Android app and in user signup he can select a image to be set in his profile. One of the feature is select friends by contact list where has a picture, name and others information about the contact. I'm using Json as result set of my request and it returns me an arraylist of users.

I don't know what's the best practice for it, do I have to upload the Base64 String to server, decode it to an image file and store it in directory and when request comes I send an URL image or do I have to send Base64 String to a database field end when request come I return the ArrayList and decode these String to a image file and load it inside my ImageView?

Can someone help me understand the difference of theses two ways?

durron597
  • 31,968
  • 17
  • 99
  • 158
lfaa
  • 13
  • 1
  • 6

2 Answers2

0

base64 encoded data will be bigger than raw data and then you yet need to decode it on client. So what's the point? Serve "normal" images, so client app does not need to do any "magic" to display it. Also you'd be able to use classes like Glide or Picasso to and delegate loading/caching etc to them /wo any hassle

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

IMHO it might be easier to go with base64 when transferring data to client using JSON. Here is one popular answer that also agrees.

But if Android apps allow you to reference the URL of an image (e.g. http://domain/path/img.png) then I would just store the URL in the DB and pass that URL from the server to the Andriod app. I think JavaFX's ImageView allows this.

Community
  • 1
  • 1
Jose Martinez
  • 11,452
  • 7
  • 53
  • 68