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?
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.
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
Related
I am currently storing an Object in a Firebase Database containing name, description and base64 of a photo. I know this is not a good practice but it works for now. I have some knowledge how to upload to a firebase storage and how to retrieve an image. Let's say I want to upload an object do a database containing name and description and also a photo but this time to the storage. And let's say there is 100 of those objects with 100 images. What should I do that each object is associated with the correct image?
Because it does not work with all objects that have saved on my local Data storage?
If I remove the "fromLocalDatastore ()" it works.
Does anyone know any solution for this?
Midia midia = noticia.getImagem().getQuery().fromLocalDatastore().getFirst();
Image which confirms that the objects are saved in DataStorage site, including including the files:
Ok, I think the problem is that local datastore does not support files at this moment (not sure but as I recall it does not). What you could do is
query the parse.com database
store the image on either internal or external storage, perhaps using the objectId as the name
now you can query the local datastore and easily locate the stored image using the objectId of the retrieved objects
Alternatively the images can be stored as a byte array as this blog suggests: http://www.cumulations.com/blogs/8/Problem-with-ParseFile-in-offline-mode
i want to build an andoid app , which will upload the image to sqlserver
i know how to save using ftp server,but i dont want to do in that way
is there any way that i can save directly to sql server
Thanks for your time guys
If you really need to save files in the database SQL server has a column type varbinary for saving BLOB objects.
http://msdn.microsoft.com/en-us/library/ms188362.aspx
You can do it by BASE64 encoding, you will obtain a string that you'll can store it into a TEXT field in your SQL DB.
And when you want to read or view the image, you'll have only to decode the string.
Here I give you a very good tutorial of how to encode
I am new to android. I would like to know how to retrieve stored images from a database. No add or delete functionality. I want to retrieve already stored images from a database. Please help me achieve this.
This answers assumes that you are retrieving images from a database in another app (because you'd already now how to retrieve images from a database that you created).
If the database is within another application, you must use a content provider. This link will redirect you to the official documentation. It covers all you will need to know about content providers.
In the most basic terms ever, to use a content provider you must first ask permission. Then you query the application that stores the database rather than the database itself (note: the application you query in turn queries the database). Therefore, you must have documentation that will provide predefined methods that must be used.
Not sure what really you want.
But if you finding a simple way to store image to database, you can try base64 image, it is like a string so simple store and read it in/from database.
To display base64 image on html, use can you
<img src="data:image/gif;base64,base64_data_here"/>
Reference to more information:
To convert your image to base64
How to convert a image into Base64 string?
To convert base64 to image:
How to convert a Base64 string into a BitMap image to show it in a ImageView?
I am accessing the datas from json, storing the datas from json in sqlite and then retrieving it and display them on screen. It takes too long time for this process. Which is the better way to reduce the time consumption instead of storing and retrieving the datas from sqlite? Can anyone help me in this issue?
You can store the JSON as plain text in a file.
A nice place to put them would be your application's cache directory.
https://developer.android.com/reference/android/content/Context.html#getExternalCacheDir()
https://developer.android.com/reference/android/content/Context.html#getCacheDir()
You can store a JSON Data in a File or in a Shared Preference. Check Saving data in android training
I also use the file system to store json. It can be easier for debugging as you can have the json.tostrong methods indent the json yo make it easier to read using the android file browser.
i make a filesystem class that accepts and returns json so apps just see the file system as a json store.