-2

I am making a quiz app and i couldn't figure out how to store my questions and answers without using SQLite or datashare I'm used to c++ so I'm searching for the equivalent of making a struct and using an array to store my data

struct item {
string Question;
string Answer1;
string Answer2;
};
item data[] ;

how can i make an equivalent of this in Android Studio, store data in it and import from it to a textView for example ??

  • 1
    Android Studio is an IDE, it has no role in dictating implementation details of a particular language other than perhaps providing some convenient features to achieve the end goal (s). – ChiefTwoPencils Jul 12 '17 at 02:14

1 Answers1

0

If I understand your question correctly, you may want to put your questions into a String array and your answers into another String array. Make sure the indices of each array match up the question with its corresponding answer.

String[] questions = {"Q1", "Q2", "Q3"};
String[] answers = {"A1", "A2", "A3");

Then, use a loop to cycle through the indices and set the text of your TextViews to the questions and answers.

questionText.setText(questions[i]);
answersText.setText(answers[i]);

If I didn't understand your question right, hopefully this answer will lead you down the right path.

Anyway, using an SQLite Database is pretty intuitive and will help with data persistence.

Tejas V
  • 28
  • 5