I'm using DBFlow to save into the database and Retrofit to call my web service. My retrofit class is the same class as my database table. Here what I did so far, but I want to know how to save data and get data using this, please send me any ideas about this
Here is my model:
@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;
}
}
And this is my retrofit call
this.questionListSubscription = this.makeUIObservable(questionService.getAllQuestions(appointmentId, 1))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
questions -> {
//save data
this.hideProgress();
},
error -> this.hideProgress()
);
Now I want to save data and get data from database after save, I am stuck with here, Please help me