Example #1
0
  public List<Teams> getAllTeams() {
    if (_local) {
      SQLiteDatabase db = this.getReadableDatabase();
      List<Teams> teams = new ArrayList<Teams>();
      String selectQuery = "SELECT * FROM " + TABLE_TEAMS;

      Log.i(LOG, selectQuery);

      Cursor c = db.rawQuery(selectQuery, null);

      if (c != null && c.moveToFirst()) {

        do {
          // create the instance of Players using cursor information
          Teams team = new Teams();
          team.settid(c.getLong(c.getColumnIndex(KEY_T_ID)));
          team.settname((c.getString(c.getColumnIndex(KEY_T_NAME))));
          team.setabbv((c.getString(c.getColumnIndex(KEY_ABBV))));
          team.setcname((c.getString(c.getColumnIndex(KEY_C_NAME))));
          team.setsport((c.getString(c.getColumnIndex(KEY_SPORT))));

          // adding to players list
          teams.add(team);
        } while (c.moveToNext());
      }
      return teams;
    } else {
      return _net.getAllTeams();
    }
  }
Example #2
0
  // get single team with name
  public Teams getTeam(String t_name) {
    if (_local) {
      SQLiteDatabase db = this.getReadableDatabase();
      // create query to select game
      String selectQuery =
          "SELECT  * FROM " + TABLE_TEAMS + " WHERE " + KEY_T_NAME + " = " + t_name;
      // Log the query
      Log.i(LOG, selectQuery);
      // perform the query and store data in cursor
      Cursor c = db.rawQuery(selectQuery, null);
      // set cursor to beginning
      if (c != null) c.moveToFirst();
      // create the instance of Teams using cursor information
      Teams team = new Teams();
      team.settid(c.getLong(c.getColumnIndex(KEY_T_ID)));
      team.settname((c.getString(c.getColumnIndex(KEY_T_NAME))));
      team.setabbv((c.getString(c.getColumnIndex(KEY_ABBV))));
      team.setcname((c.getString(c.getColumnIndex(KEY_C_NAME))));
      team.setsport((c.getString(c.getColumnIndex(KEY_SPORT))));

      return team;
    } else {
      return _net.getTeam(t_name);
    }
  }