Android DBFLOW With Retrofit

时间:2017-07-21 04:04:16

标签: android retrofit2 dbflow

我使用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()
            );

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

0 个答案:

没有答案