This code below works with both a DAO and dBhelper class. I have 3 tables with approx 6 columns for each, but I'm fed up "playing" with the field names for every method (insert, delete and so on..) and would like to replace that code below using a for-loop, browsing both the field names and data to be inserted into the dB.
So the question is :
how to replace such an expression MySQLiteHelper.COLUMN_ID to MySQLiteHelper.columnName sothat I can embed this oneliner into a for-loop.
private String[] allColumns = {
MySQLiteHelper.COLUMN_level_1,
MySQLiteHelper.COLUMN_level_2,
MySQLiteHelper.COLUMN_level_3
};
String[] mydata = myobject.getData();
// Here I would like to use a for-loop for the following lines
values.put(MySQLiteHelper.COLUMN_level_1, mydata[0]);
values.put(MySQLiteHelper.COLUMN_level_2, mydata[1]);
values.put(MySQLiteHelper.COLUMN_level_3, mydata[2]);