我正在尝试使用 Room 将 base64 值保存到我的 sqlite 数据库中,但由于某种原因它没有保存。好吧,我假设它没有保存,因为当我尝试读取具有base64列的表时,它会返回除base64列之外的所有其他列的值。我做错了什么?
我的实体:
@Entity(tableName = "healthCareWorkerInformation",
foreignKeys = @ForeignKey(
entity = HealthCareWorker.class,
parentColumns = {"id"},
childColumns = {"hcwId"},
onDelete = ForeignKey.CASCADE),
indices = @Index(
value = {"hcwId"}))
public class HealthCareWorkersInformation {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "hcwInfoId")
private long id;
private long hcwId;
//@ColumnInfo(typeAffinity = ColumnInfo.BLOB)
private String base64Image;
private String updatedAt = new SimpleDateFormat("dd MM yyyy, HH:mm",
Locale.getDefault()).format(Calendar.getInstance().getTime());
public HealthCareWorkersInformation() {
}
@Ignore
public HealthCareWorkersInformation(long hcwId) {
this.hcwId = hcwId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getHcwId() {
return hcwId;
}
public void setHcwId(long hcwId) {
this.hcwId = hcwId;
}
public String getBase64Image() {
return base64Image;
}
public void setBase64Image(String base64Image) {
this.base64Image = base64Image;
}
public String getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}
}
我的道:
@Insert
void insertHealthCareWorkerInformation(HealthCareWorkersInformation healthCareWorkersInformation);
@Query("SELECT * FROM HEALTHCAREWORKERINFORMATION")
LiveData<List<HealthCareWorkerInformation>> getHCWInfo();
我发送的示例数据:
除 base64 列外,其他所有内容都将保存。请协助。
翻阅古今
相关分类