use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class UpdateDB method updateQuestionRelation.
public static void updateQuestionRelation(Context context) throws IOException {
FileCsvs fileCsvs = new FileCsvs();
fileCsvs.saveCsvFromAssetsToFile(PopulateDB.QUESTION_RELATIONS_CSV);
List<QuestionRelation> questionRelations = QuestionRelation.listAll();
HashMap<Long, Question> questionIds = RelationsIdCsvDB.getQuestionIdRelationCsvDB(context);
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.QUESTION_RELATIONS_CSV)), SEPARATOR, QUOTECHAR);
String[] line;
int i = 0;
while ((line = reader.readNext()) != null) {
boolean added = false;
if (i < questionRelations.size()) {
populateQuestionRelation(line, questionIds, questionRelations.get(i)).save();
} else {
QuestionRelation questionRelation = populateQuestionRelation(line, questionIds, null);
questionRelation.insert();
}
i++;
}
}
Aggregations