保存的数据与数据库内容不对应 SQLite litepal

Data saved not corresponding with database content SQLite litepal

我是 android 开发的新手。

我正在尝试将数据从 json string

保存到数据库
[{
    "question": "Who is the 'Modern Love' rock star singer?",
    "imageUrl": "https://postimg.cc/2VL1Y1jd",

    "answerOptions": [
        "Jimi Hendrix",
        "David Bowie",
        "Jim Morrison",
        "Elvis Presley"
    ],

    "correctAnswer": "David Bowie"
}]

在 mainActivity onCreate 我有:

for (int i = 0; i < list.size(); i++) {
    Quiz quiz = list.get(i);
    quiz.save();
}

效果非常好,因此当我调试时我有:

但是当我查看数据库文件时,缺少 answerOptions 的子列表:

因此,当我尝试 runOnUiThread 时,litePal.findall 的列表与 Quiz.class

不对应
runOnUiThread(new Runnable() {
    @Override
    public void run() {
        List<Quiz> list = LitePal.findAll(Quiz.class);
        QuizAdapter quizAdapter = new QuizAdapter(list, MainActivity.this);
        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setAdapter(quizAdapter);
    }
});
class Quiz extends LitePalSupport {
    String question;
    String imageUrl;
    String [] answerOptions;
    String correctAnswer;
}

这种方法有没有可能solution/alternative?

我通过更改数据结构解决了这个问题:

[{
    "question": "Who is the 'Modern Love' rock star singer?",
    "imageUrl": "https://postimg.cc/2VL1Y1jd",
    "one": "Jimi Hendrix",
    "two": "David Bowie",
    "three": "Jim Morrison",
    "four": "Elvis Presley",
    "correctAnswer": "David Bowie"
}]

然后相应地调整我的class:

public class Quiz extends LitePalSupport {
    String question;
    String imageUrl;
    String one;
    String two;
    String three;
    String four;
    String correctAnswer;
}

然后在我的适配器中,我将各个字符串添加到一个数组中

List<String> answerOptions = new ArrayList<>();
answerOptions.add(quiz.one);
answerOptions.add(quiz.two);
answerOptions.add(quiz.three);
answerOptions.add(quiz.four);
...
quizHolder.createRadioButtons(answerOptions.toArray(new String[0]));
...