0

I want save an image in sqliteconnection, and I don't know how to do it. When I save name of Image: (image1.jpg) for exemple, and I try to implement it in another place, I don't see the Image!!

private async void SaveBtn_Clicked(object sender, EventArgs e)
{
    SaveExercices y = JsonConvert.DeserializeObject<SaveExercices>(ExerciceCree);
    y.ExerciceName = Exercicename.Text;
    y.ExerciceImage=ImageName;           ///////////How Can I save It??////////////
    ExerciceCree = JsonConvert.SerializeObject(y);
    TabsPage.db.Insert(new Save()
    {
        Myexercicejson = ExerciceCree
    });

    string a = TabsPage.db.Table<Save>().ToList()[TabsPage.db.Table<Save>().ToList().Count-1].Myexercicejson;
    SaveExercices x = JsonConvert.DeserializeObject<SaveExercices>(a);
   
    ArticleCardPage.liste.Add(x);

    await DisplayAlert("Save", "Saved with successful", "Ok");
}
General Grievance
  • 4,555
  • 31
  • 31
  • 45
YBENZAKOUR
  • 11
  • 2
  • 1
    saving image data in the db is generally not a good idea. Instead, store the image in the file system and store the path of the image in the db. – Jason Jul 11 '20 at 23:59
  • What @Jason said is true, but if still, you want to store it in DB, store it as a Hex string or Byte array. – Sankarann Jul 12 '20 at 07:48
  • @Jason Thank's. but if you can give me exemple of code!! because I'm beginner in xamarin forms, And it's the first time when I do that!!! – YBENZAKOUR Jul 13 '20 at 18:29

0 Answers0