Store ImageResource object in SQLite data base

vkt_rbvkt_rb USMember ✭✭✭

Hi everyone, I'm trying to store an ImageResource object in a local SQlite, but I don't know what is the best way to do it because, what I need to do is save the path of a selected image and save it in a local base in SQLite to be used before (I already could save the path but I did in a ImageResource object), So I was trying to store the path in the SQLite but I've couldn't still do it, this is the code that I was trying to do:

    public class appConfig
    {
        [PrimaryKey, AutoIncrement]
        public int Identificador { get; set; }
        public bool Estado { get; set; }
        public int CodigoVerificacion { get; set; }
        public string CodigoCliente { get; set; }
        public string CodigoImpulsador { get; set; }
        public string Nombre { get; set; }
        public string Apellido1 { get; set; }
        public string Apellido2 { get; set; }
        public string Cedula { get; set; }
        public string Celular { get; set; }
        public string Correo { get; set; }
        public int Pais { get; set; }
        public int Provincia { get; set; }
        public int Canton { get; set; }
        public int Distrito { get; set; }
        public string Detalle { get; set; }
        public int _iActivo_U { get; set; }
        public int _iAdministrador { get; set; }
        public Xamarin.Forms.ImageSource _sRutaAvatar { get; set;} <-- trying to store the ImageResource object in here
    }

But when I run my App it showed the exception attached, I would like to know where is the bestway to store the ImageSource object, and that I can use the path again in a Image later.

Best Answer

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited October 2016

    I'm trying to store an ImageResource object in a local SQlite,

    Storing images in databases is frowned upon nearly everyplace including real SQL database on desktop PC.
    Then complicate that with the reality the SQLite is really a flat file and you'll bog down your performance something horrible when it has to scan past huge blob of data for each record.
    Its just not a good way to go.

    Instead, store the string path to the image file, and just keep a folder of images on the device.

    So I was trying to store the path in the SQLite but I've couldn't still do it,

    You can't put any string into your SQLite database? Or just an issue with this model?

  • vkt_rbvkt_rb USMember ✭✭✭
    edited October 2016

    Hi @ClintStLaurent to be honest at the beging what I was looking for was trynig tho get the string path of the image file to be stored in the database, but What I needed was get that path from a selected image by the file explorer, so after looking in differents posts, at the end the best way that I could got, was got the path of the selected image using the Media Plugin, but with this media plugging the path was obtained with a ImageSource, I 've seen that I could Cast my ImageSource object into a array Byte, and try to store the array in the DataBase, but all the examples that I've seen them still not working for my solution.

Sign In or Register to comment.