0

I am making an app using SQLite in Android.

I want to insert 500 rows to my table, but I don't really know how to insert many rows. I tried to insert 10 rows by typing dbInsert() code but typing 500 rows took a lot of codes and made my app slow. These are my codes.

 public WordDBRecord open() throws SQLException { dbHelper = new WordDBHelper(context, "WordDB", null, 1); database = dbHelper.getWritableDatabase(); dbInsert("KeyWordDB", "Movie", "Terminator"); dbInsert("KeyWordDB","Sports","Soccer"); dbInsert("KeyWordDB","City","BeiJing"); dbInsert("KeyWordDB","Actor","Tom"); dbInsert("KeyWordDB","NBA Player","MJ"); return this; } public void dbInsert(String tableName, String category, String word) { Log.d(TAG, "Insert Data "); ContentValues contentValues = new ContentValues(); contentValues.put("CATEGORY", category); contentValues.put("WORD", word); long id = database.insert(tableName, null, contentValues); Log.d(TAG, "id: " + id); } 

I have searched method, but most told me to use ArrayList and for loops. However, as a beginner I don't really understand this method.

So my question is How can I insert 500 rows using for loops or ArrayList?

I will be grateful, if someone answers my question Thank you

1
  • Use loop, it's very easy :D. Commented Dec 16, 2019 at 3:49

1 Answer 1

1

try to : INSERT THOUSANDS OF DATA IN SECONDS

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.