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 thro
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;
}