How insert image in room persistence library?

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

Leave a Comment