Android:Realm在初始运行时未创建所有表

时间:2018-10-28 15:36:50

标签: android realm

我无法弄清楚为什么Realm在我的android应用程序初次运行时不创建所有表。当应用运行时,仅创建6个表中的2个。我遵循了文档,所有模型类都必须扩展RealmObject类。我正在使用最新版本的Realm(5.7.0)。

enter image description here

这是我未添加到领域架构中的类之一:

public class Category extends RealmObject implements Parcelable {

@PrimaryKey
@SerializedName("categoryID")
private int categoryID;
@SerializedName("name")
private String name;
@SerializedName("dateAdded")
private String dateAdded;
@SerializedName("isDeleted")
private int isDeleted;

public Category(int categoryID, String name, String dateAdded, int isDeleted) {
    this.categoryID = categoryID;
    this.name = name;
    this.dateAdded = dateAdded;
    this.isDeleted = isDeleted;
}
public Category() { }

protected Category(Parcel in) {
    categoryID = in.readInt();
    name = in.readString();
    dateAdded = in.readString();
    isDeleted = in.readInt();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(categoryID);
    dest.writeString(name);
    dest.writeString(dateAdded);
    dest.writeInt(isDeleted);
}

@Override
public int describeContents() {
    return 0;
}

public static final Creator<Category> CREATOR = new Creator<Category>() {
    @Override
    public Category createFromParcel(Parcel in) {
        return new Category(in);
    }

    @Override
    public Category[] newArray(int size) {
        return new Category[size];
    }
};

public int getCategoryID() {
    return categoryID;
}

public void setCategoryID(int categoryID) {
    this.categoryID = categoryID;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDateAdded() {
    return dateAdded;
}

public void setDateAdded(String dateAdded) {
    this.dateAdded = dateAdded;
}

public int getIsDeleted() {
    return isDeleted;
}

public void setIsDeleted(int isDeleted) {
    this.isDeleted = isDeleted;
}

}

这是一个领域确实添加到架构中的类:

public class ClientInfo extends RealmObject implements Parcelable {

@PrimaryKey
@SerializedName("clientInfoID")
private int clientInfoID;
@SerializedName("platform")
private String platform;
@SerializedName("dateAdded")
private String dateAdded;
@SerializedName("description")
private String description;
@SerializedName("codeName")
private String codeName;
@SerializedName("versionNumber")
private double versionNumber;
@SerializedName("status")
private String status;
@SerializedName("isDeleted")
private int isDeleted;

public ClientInfo() {

}

protected ClientInfo(Parcel in) {
    clientInfoID = in.readInt();
    platform = in.readString();
    dateAdded = in.readString();
    description = in.readString();
    codeName = in.readString();
    versionNumber = in.readDouble();
    status = in.readString();
    isDeleted = in.readInt();
}

public static final Creator<ClientInfo> CREATOR = new Creator<ClientInfo>() {
    @Override
    public ClientInfo createFromParcel(Parcel in) {
        return new ClientInfo(in);
    }

    @Override
    public ClientInfo[] newArray(int size) {
        return new ClientInfo[size];
    }
};

public int getClientInfoID() {
    return clientInfoID;
}

public void setClientInfoID(int clientInfoID) {
    this.clientInfoID = clientInfoID;
}

public String getPlatform() {
    return platform;
}

public void setPlatform(String platform) {
    this.platform = platform;
}

public String getDateAdded() {
    return dateAdded;
}

public void setDateAdded(String dateAdded) {
    this.dateAdded = dateAdded;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public String getCodeName() {
    return codeName;
}

public void setCodeName(String codeName) {
    this.codeName = codeName;
}

public double getVersionNumber() {
    return versionNumber;
}

public void setVersionNumber(double versionNumber) {
    this.versionNumber = versionNumber;
}

public String getStatus() {
    return status;
}

public void setStatus(String status) {
    this.status = status;
}

public int getIsDeleted() {
    return isDeleted;
}

public void setIsDeleted(int isDeleted) {
    this.isDeleted = isDeleted;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(clientInfoID);
    dest.writeString(platform);
    dest.writeString(dateAdded);
    dest.writeString(description);
    dest.writeString(codeName);
    dest.writeDouble(versionNumber);
    dest.writeString(status);
    dest.writeInt(isDeleted);
}

}

我使用JobIntentService从Web API中获取数据...对该API的所有调用均成功,并且在调用写入事务时,领域也不会引发异常。我尝试运行迁移,但似乎没有效果。没有被领域接收的类可能是什么问题?

谢谢

0 个答案:

没有答案