Is is there a way to save a image on SQLite database? All of the tutorials I've search so far are only available in android studio/java. I need a c# sample of saving image on SQLite database. Can someone give some sample link or teach me how to do it? Thanks in advance
Answers
Hello @enohara,
for me , you need to try to convert the sample in java in c# that's a good exercice for you and for the futur you'll see often when we meet a problem you'll find a solution perhpas in java ...
it's my opinion ...
now, nothing found about this ...but try the sample in java and if you meet some problem post it here ...
i will help you ..
@ChristopheBERNARD thanks for the advice sir,
I already get the flow of saving on JAVA/Android studio.
I need to convert my image to byte array / base64, then save it to my SQLite database.
and when it comes to retrieving, I'll get the Base64string file android convert it to bitmap.
But I can't find a codes for android xamarin when it comes to converting android retrieving.
I tried searching but most of the results are also Java/android studio.
I found some in converting but most of it are in C# (Windows form) and I can't convert it to xamarin android.
Here Sir:
https://stackoverflow.com/questions/18827081/c-sharp-base64-string-to-jpeg-image
https://stackoverflow.com/questions/36973960/convert-base64-string-to-bitmap-or-image-xamarin-or-android
I already know the procedure, but I still don't know the codes.
Hope you help me with this Sir. Thanks Again
Try this and insert it into sql lite
`
public static string ConvertBitmapToString(Bitmap theBitmap)
{
string strImage = string.Empty;
using (var stream = new System.IO.MemoryStream())
{
theBitmap.Compress(Bitmap.CompressFormat.Png, 25, stream);
var bytes = stream.ToArray();
strImage = Convert.ToBase64String(bytes);
}
`
I'll give it a try Sir, thank you for this.
))))
I'll inform you if it's working
@Enohara
You havent give a update on this.
I have the same problem have searched for days and cant find a good solution
And one part more.
When you have the method
how do i but the image into the method, for me it just say i have inserted a integer
ConvertBitmapToString(Resorce.drawing.item)
If you have to handle big images, it is better(i think...) to save your images inside mobile storage. And when you need your image, retreive it from a storage path.
Example
First step - Save image name in sqlite(or full path) then save your image to this path
Second step - Select image name(or full path) from sqlite, and show it inside an imageview...