I am using room persistence library for my android application, Now I have to insert image in my db. I successfully define @Entity for the primitive data type. and also through converter class, i stored all object, date, time. Now I have to store Image. I am not able to understand how we define Column info and entity and how we insert that data as well as read data from the table.
What is the maximum size of data which inserted into the single row? What is max and min size of data in one field in Android SQLite?
It is usually not recommended to store image data into the database. But however if it is required for your project then you can do so.
Image data are usually stored into db using BLOB data type, Room also provide support for BLOB data type Documentation
You can declare your entity class as mentioned below to store Image data.
As Pinakin mentioned, it is not recommended to store an image into database and file path would be better but if it is required to store image I would suggest compress the image to below 2 MB (here is an example) to avoid breaking app. Room supports BLOB for image. Entity class in kotlin:
ImageTest.kt
ImageDao.kt
Databse.kt
In DatabaseHelper something like
Correct me if I am wrong. Hope this helps someone out there