示例#1
0
  /**
   * Checks the password of the user
   *
   * @param password - The password of the user, SHA-1 encoded
   * @return If the password is correct
   */
  public boolean checkPassword(String password) {
    Cursor c =
        Database.getInstance()
            .getReadableDatabase()
            .rawQuery("SELECT password FROM USER WHERE name = \"" + user + "\"", null);
    c.moveToFirst();

    return isAuthenticated = password.equals(c.getString(0));
  }
示例#2
0
  private boolean existsUser(String user) {
    Cursor c =
        Database.getInstance()
            .getReadableDatabase()
            .rawQuery("SELECT COUNT(*) FROM USER WHERE name = \"" + user + "\";", null);

    c.moveToFirst();
    return c.getInt(0) == 1;
  }