Esempio n. 1
0
  private void getProjects() {
    projects = new ArrayList<String>();
    mProjects = new ArrayList<Project>();
    dbhelper.open();
    Cursor c = dbhelper.getAllProjects();
    if (c.moveToFirst()) {
      do {
        Project tmp = new Project();
        tmp.setCount(c.getInt(c.getColumnIndex(DbAdapter.KEY_COUNTER)));
        tmp.setRowId(c.getLong(c.getColumnIndex(DbAdapter.ROW_ID)));
        tmp.setName(c.getString(c.getColumnIndex(DbAdapter.KEY_PROJECTNAME)));
        mProjects.add(tmp);
        projects.add(tmp.getName());

      } while (c.moveToNext());
    }
    c.close();
    dbhelper.close();
  }
    @Override
    protected ArrayList<Project> doInBackground(Integer... params) {
      ArrayList<Project> list = new ArrayList<Project>();

      dbadapter.open();
      Cursor c = dbadapter.getAllProjects();
      Project tmp = new Project();
      if (c.moveToFirst()) {
        do {
          tmp = new Project();
          tmp.setRowId(c.getLong(c.getColumnIndex(DbAdapter.ROW_ID)));
          tmp.setName(c.getString(c.getColumnIndex(DbAdapter.KEY_PROJECTNAME)));
          tmp.setCount(c.getInt(c.getColumnIndex(DbAdapter.KEY_COUNTER)));

          list.add(tmp);

        } while (c.moveToNext());
      }
      c.close();
      dbadapter.close();
      return list;
    }