I am inserting a row that has following 4 columns:
- Day
- Task
- Task Description
- TaskTime
But only two columns are inserted successfully i.e. Day and Task. However, Task Description and TaskTime are null apparently.
public Task createTask(String day, String task, String taskDescription, String taskTime) {
ContentValues values = new ContentValues();
values.put(MySQLiteHelper.COLUMN_DAY, day);
values.put(MySQLiteHelper.COLUMN_TASK, task);
values.put(MySQLiteHelper.COLUMN_TASK_DESCRIPTION, taskDescription);
values.put(MySQLiteHelper.COLUMN_TASK_TIME, taskTime);
System.out.println("Inserting task:" + task + " taskDescription:" + taskDescription + " taskTime:" + taskTime);
long insertId = database.insert(MySQLiteHelper.TABLE_TASK, null,
values);
Cursor cursor = database.query(MySQLiteHelper.TABLE_TASK,
allColumns, MySQLiteHelper.COLUMN_ID + " = " + insertId, null,
null, null, null);
cursor.moveToFirst();
Task newTask = cursorToTask(cursor);
System.out.println("Fetching cursor task:"+newTask.getTask()+" taskDescription:"+newTask.getTaskDescription()+" taskTime:"+newTask.getTaskTime());
cursor.close();
return newTask;
}
I am using the aforementioned code to insert the data into the database. Could anyone explain why only two columns are getting inserted into the database instead of of 4 columns?
Aucun commentaire:
Enregistrer un commentaire