我正在开发Android上的测验应用程序。我问过有人存储数据。所有人都喜欢Sqlite数据库。我做到了。 但为什么我不能使用字符串数据来显示数据,而不是Sqlite数据库? 实施例用于更详细地:Android - String和Sqlite数据库上的数据有什么区别?
- 储存在列表:
List<String> questions = new ArrayList<String>(); questions.add("Question A?"); questions.add("Question B?"); questions.add("Question C?"); List<String> answers = new ArrayList<String>(); answers.add("Answer A"); answers.add("Answer B"); answers.add("Answer C");
- 商店SQLite中
Question question0 = new Question("Question A?", "Answer A"); Question question1 = new Question("Question B?", "Answer B"); Question question2 = new Question("Question C?", "Answer C"); dbHelper.createQuestion(question0); dbHelper.createQuestion(question1); dbHelper.createQuestion(question2); List<String> listQuestions = new ArrayList<String>(); listQuestions = dbHelper.getAllQuestions();
你*可以*使用字符串。要了解为什么你不想*,只需尝试一下。 –
'Sqlite'永久保存数据,'List'暂时保存.. –
内存或性能有问题吗?我看到这两种方法都需要先加String, – kidsoul