2

我正在使用 DBFlow 保存到数据库中,并使用 Retrofit 来调用我的 Web 服务。我的改造类与我的数据库表是同一类。到目前为止我做了什么,但我想知道如何使用它来保存数据和获取数据,请给我任何关于这个的想法

这是我的模型:

@Table(database = SimplifyaDatabase.class, name = "Question")
public class Question extends BaseModel {


@Column
@PrimaryKey
@SerializedName("question_id")
@Expose
private int questionId;

@Column
@SerializedName("question")
@Expose
private String question;

@Column
@SerializedName("question_answer_id")
@Expose
private String questionAnswerId;

@Column
@SerializedName("explanation")
@Expose
private String explanation;

@Column
@SerializedName("category_id")
@Expose
private String categoryId;


@SerializedName("citations")
@Expose
private List<Citation> citations = null;
@SerializedName("answers")
@Expose
private List<Answer> answers = null;


public int getQuestionId() {
    return questionId;
}

public void setQuestionId(int questionId) {
    this.questionId = questionId;
}

public String getQuestion() {
    return question;
}

public void setQuestion(String question) {
    this.question = question;
}

public String getQuestionAnswerId() {
    return questionAnswerId;
}

public void setQuestionAnswerId(String questionAnswerId) {
    this.questionAnswerId = questionAnswerId;
}

public String getExplanation() {
    return explanation;
}

public void setExplanation(String explanation) {
    this.explanation = explanation;
}

public String getCategoryId() {
    return categoryId;
}

public void setCategoryId(String categoryId) {
    this.categoryId = categoryId;
}

public List<Citation> getCitations() {
    return citations;
}

public void setCitations(List<Citation> citations) {
    this.citations = citations;
}

public List<Answer> getAnswers() {
    return answers;
}

public void setAnswers(List<Answer> answers) {
    This. answers = answers;
}
}

这是我的改造电话

this.questionListSubscription = this.makeUIObservable(questionService.getAllQuestions(appointmentId, 1))
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    questions -> {
                        //save data


                        this.hideProgress();

                    },
                    error -> this.hideProgress()
            );

现在我想保存数据并在保存后从数据库中获取数据,我被困在这里,请帮助我

4

0 回答 0