Chapter7 RemoveTask, book example is not working
Hello, I'm trying to complete the missing code when removing an item, my problem is with the id type.. thus, KEY_ID is of String type, but when calling removetask is expecting an int.
Your help is highly appreciated.
Thank you.
//id item creation
ToDoItem newItem = new ToDoItem(task, new Date(created), idDb);
//constructor to accept the id from the database
public ToDoItem(String _task, Date _created, String _idDB) {
task = _task;
created = _created;
idDB = _idDB;
}
//pass the id
public boolean removeTask(ToDoItem idDb) {
return db.delete(DATABASE_TABLE, KEY_ID + "=" + idDb, null) > 0;
}
// calling from the TodoLIst activity
toDoDBAdapter.removeTask(todoItems.size()-_index);
|