Reputation: 1080
I am using mysql database, i have a web site. So now i decided to create a mobile application. But i have some image in ftp, and their path saved as a varchar in mysql.
I connect to mysql remotely in Android app. But i dont know which is the best way to show image on Android app.
I have 2 way to show it. First one is i can get an image path and show on an url in image view or the other one is i saved that images blob file in mysql and get the base64 encoded text and show. But which is the better way ?
Upvotes: 0
Views: 324
Reputation: 488
Google has released an awesome library that handles HTTP requests and its main purpose is literally simplify developers life when they need to manage a huge amount of web requests, providing image caching solutions and avoiding the problems of concurrent programming, thread syncronization etc...
I'm talking about Volley
This great solution is exactly the solution to your problem, why? It's because it exposes a clear way to request remote image resources and caching them directly inside the app storage, without the inconvenient of using mobile network each time you open the app, refresh a fragment/activity or add a new element to a listview object.
This is done by implementing an image request method.
So, I think you should store your images on disk and save just their path inside the database, and then, from the app, make a request to your server, Volley will take care of getting the image and raising a callback when the request has been completed.
Simple and clear.
Upvotes: 1