コード例 #1
0
  public List<GroupsModel> getGroupsData() {
    List<GroupsModel> groupsModelList = new ArrayList<GroupsModel>();
    SQLiteDatabase db = this.getReadableDatabase();

    String query = "SELECT * FROM " + TABLE_GROUPS;

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

    if (c.moveToFirst()) {
      do {
        GroupsModel groupsModel = new GroupsModel();
        groupsModel.setGroupId(new Integer(c.getInt(c.getColumnIndex(GROUP_ID.trim()))));
        groupsModel.setGroupName(c.getString(c.getColumnIndex(GROUP_NAME.trim())));

        groupsModelList.add(groupsModel);
      } while (c.moveToNext());
    }

    db.close();
    return groupsModelList;
  }