1

I would like to create an application which accepts image in android convert it to base64string. The resulting base64 string will be sent to the rest API where it is converted to byte array and store in SQL DB. Is this the best possible way to store image in SQL DB or there any other possibilities?

2 Answers 2

1

Better practice is to store the string of the location on the filesystem where the service that executes your database call is hosted. When you retrieve the 'image' you retrieve the location and use that to pull back the image from the file system rather than storing the entire binary on the database.

Sign up to request clarification or add additional context in comments.

4 Comments

what if the application is launched from a different device for the same user? What if the file is deleted? or what if the file location have been moved to a different place?
The file should be located on the REST Service server - not the client device. If a file is moved or deleted on the server, it should be done by a corresponding REST Service call that also updates the database.
Fine now i get it. Can you please tell me why i should not store it in varbinary?
The main reason is that it forces more data transfer to retrieve it (unless the REST Service is hosted on the same server as the database - in which case, it's a bit more subjective.) It also needlessly increases the size of your database, but with modern databases and storage, that's probably much less of a concern.
0

This is My way , I will just say in simple way .first i create global path like "yourpath/"

then I Get image from server and Store it in device storage in the global path

then I Store only image name like imagename.jpg to the sqlite

at last I use image name stored in sqlite and concatenate with global path to display images whenever I want

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.