1

I'm currently trying to create an Flashcard application, in which the user can either create his own cards/notes or use pre-defined cards. The idea is to have around 500 to 1000 cards to be inserted on the database right after its creation. But how do I insert this initial data?

The only solution I could come up with is creating each one of the cards inside the "onCreate()" method of my "SQLiteOpenHelper" class, which would lead to repeating 500+ times the insert process:

db.execSQL("INSERT INTO table (column1, column2, columnN) VALUES(...)");

Is it the right thing to do? Would it work, and if so is it a good method or would I have any problems by doing it this way?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
poteto0909
  • 11
  • 2
  • In the database of your application, create a table called `pre_cards`. Populate it with 1000 cards. If the user chooses to use pre-defined cards, you can copy the data from pre_cards to the appropriate table by doing `insert into real_table select * from pre_cards;`. You can pre-populate pre_cards table by importing data from a CSV. To create a CSV, you can use a spreadsheet, enter data in it and save it as a CSV. – zedfoxus May 09 '22 at 01:25

0 Answers0