我正在使用Android应用程序并使用Realm来保存数据,但仅在一种情况下,我的数据属性没有被保存,没有迁移架构是新的,这是我的代码
public class ContractAttachments extends RealmObject {
@Required
private String nameOfFile;
private String pathOfFile;
public String getNameOfFile() {
return nameOfFile;
}
public void setNameOfFile(String nameOfFile) {
this.nameOfFile = nameOfFile;
}
public String getPathOfFile() {
return pathOfFile;
}
public void setPathOfFile(String pathOfFile) {
this.pathOfFile = pathOfFile;
}
}
realm.beginTransaction();
ContractAttachments attachment = new ContractAttachments();
attachment.setPathOfFile(file.getAbsolutePath());
attachment.setNameOfFile("nome");
realm.copyToRealm(attachment);
realm.commitTransaction();