如何为实体架构师组件设计模型?

时间:2018-12-16 09:36:47

标签: android android-room android-architecture-components android-livedata

我从json获取价值(API),并且像下面这样创建了model

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

        @Override
        public ClassesModel[] newArray(int size) {
            return new ClassesModel[size];
        }
    };
    @SerializedName("status")
    @Expose
    private String status;
    @SerializedName("0")
    @Expose
    private _0 _0 = null;

    public ClassesModel() {

    }

    protected ClassesModel(Parcel in) {
        readFromParcel(in);
    }

    public String getStatus() {
        return status;
    }

    public _0 get0() {
        return _0;
    }

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

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeString(status);
        parcel.writeParcelable(_0, flags);
    }

    private void readFromParcel(Parcel in) {
        this.status = in.readString();
        this._0 = in.readParcelable(_0.class.getClassLoader());
    }

public static class _0 implements Parcelable{
//Some code
}
public static class Userinfo implements Parcelable{
//Some code
}
public static class Teacher implements Parcelable{
//Some code
}
public static class Quiz implements Parcelable{
//Some code
}
public static class Enroll implements Parcelable{
//Some code
}
public static class Detail__ implements Parcelable{
//Some code
}
public static class Detail_ implements Parcelable{
//Some code
}
public static class Detail implements Parcelable{
//Some code
}
public static class Adobeconnect implements Parcelable{
//Some code
}
public static class CourseInfo implements Parcelable{
//Some code
}
public static class Assign implements Parcelable{
//Some code
}
}

但是我正在将源代码转换为architect component

如何将上述模型转换为实体以保存在sqlite中?

当我将所有值保存在Sqlite中时,我需要选择所有这些值。

在上述模型中,我有多个类,例如AssignCourseInfo,并且...它们具有多个值。我认为我应该为每个类创建单独的table,并且所有tables都应具有查询关系!

我该怎么办?

0 个答案:

没有答案