Retrieve task information

  1. Import the required classes and interfaces.
    import java.util.Enumeration;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.ToDo;
    import javax.microedition.pim.ToDoList;
    
  2. Invoke ToDoList.items() on the task list to retrieve an enumeration.
    ToDoList todoList = 
       (ToDoList)PIM.getInstance().openToDoList(PIM.TODO_LIST, PIM.READ_ONLY);
    Enumeration enum = todoList.items();
  3. Invoke ToDo.getFields() to retrieve an array of IDs for fields that have data for a particular ToDo item.
  4. Invoke PIMItem.getString() to retrieve the field values.
    while (enum.hasMoreElements()) 
    {
       ToDo task = (ToDo)enum.nextElement();
       int[] fieldIds = task.getFields();
       int id;
       for(int index = 0; index < fieldIds.length; ++index) 
       {
          id = fieldIds[index];
          if(task.getPIMList().getFieldDataType(id) == STRING) 
          {
             for(int j=0; j < task.countValues(id); ++j) 
             {
                String value = task.getString(id, j);
                System.out.println(task.getFieldLable(id) + "=" + value);
             }
          }
       }
    }
Next topic: Export a task
Previous topic: Save a task

Was this information helpful? Send us your comments.