コード例 #1
0
  /**
   * Add a group to the database
   *
   * @param group The group to be added
   */
  public void addGroupToGroupDatabase(Group group) {
    ContentValues values = new ContentValues();

    values.put(GroupColumns._ID, group.getId());
    values.put(GroupColumns.GROUP_NAME, group.getName());

    context.getContentResolver().insert(GroupColumns.CONTENT_URI, values);

    Log.i("USER GROUP MANAGER", "Group: " + group.getName() + " added to the database");
  }
コード例 #2
0
  /**
   * Add a user to a group in the database
   *
   * @param group The group the user should be added to
   * @param user The user to be added
   */
  public void addUserToAGroupInTheDatabase(Group group, User user) {
    ContentValues values = new ContentValues();
    values.put(GroupColumns._ID, group.getId());
    values.put(UserColumns.USER_NAME, user.getUserName());

    System.out.println(userExistsInGroup(group, user));
    if (!userExistsInGroup(group, user)) {
      context.getContentResolver().insert(UserGroupProvider.CONTENT_URI, values);
    }
    Log.i(
        "USER GROUP MANAGER",
        "User: "******" added to group: " + group.getName());
  }
コード例 #3
0
  /**
   * Removes a user from a group in the database
   *
   * @param group The group the user should be removed from
   * @param user The user to be removed
   */
  public void removeUserFromAGroupInTheDatabase(Group group, User user) {

    String where =
        GroupColumns._ID
            + " = '"
            + group.getId()
            + "'"
            + " AND "
            + UserColumns.USER_NAME
            + " = '"
            + user.getUserName()
            + "'";
    context.getContentResolver().delete(UserGroupProvider.CONTENT_URI, where, null);

    Log.i(
        "USER GROUP MANAGER",
        "User: "******" removed from group: " + group.getName());
  }