In my application, after the user presses the appropriate button, an activity starts that creates a database with one table with two columns. The thing I can't seem to get is: I would like one of the columns to automatically fill with the days of the week so that when I return a cursor over the database for the listActivity, the days are shown. I can get the database to build but I can't seem to get the column to fill with the days. I tried this
public void installDays()
{
String[] day = new String[7];;
ContentValues initialValues = new ContentValues();
day[0] = "Monday";
day[1] = "Tuesday";
day[2] = "Wednesday";
day[3] = "Thursday";
day[4] = "Friday";
day[5] = "Saturday";
day[6] = "Sunday";
for(int i = 0; i < 7; i++)
{
initialValues.put(KEY_DAY, day[i]);
}
menuDb.insert(DATABASE_TABLE, null, initialValues);
}
but that didn't work. Then I tried this:
if(rowId == 0)
{
menuDbHelper.createMenu("Monday", "", "", "");
menuDbHelper.createMenu("Tuesday", "", "", "");
menuDbHelper.createMenu("Wednesday", "", "", "");
menuDbHelper.createMenu("Thursday", "", "", "");
menuDbHelper.createMenu("Friday", "", "", "");
menuDbHelper.createMenu("Saturday", "", "", "");
menuDbHelper.createMenu("Sunday", "", "", "");
//menuDbHelper.installDays();
rowId = 1;
}
That works but its no good, if you hit the back button and come back to that activity it just adds them all over again and then I have fourteen days. What am I doing wrong here? I am new to Java so take it easy on me.