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.
@Entity(tableName = "test") public class Test{ @PrimaryKey @ColumnInfo(name = "_id") private int id; @ColumnInfo(typeAffinity = ColumnInfo.BLOB) private byte[] image; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With