Exemplo n.º 1
0
  public static clsUsuario Buscar(Context context) {
    clsUsuario entidad = null;
    bdSQLite admin = new bdSQLite(context, null);
    SQLiteDatabase bd = admin.getWritableDatabase();
    if (bd != null) {
      String query =
          "select int_id_usuario,str_nombres,str_apellido_paterno,str_apellido_materno,"
              + "str_usuario,str_clave,str_email,str_dni,str_telefono,str_direccion,"
              + "bol_sexo,byte_foto,int_id_persona from "
              + NOMBRE_TABLA;

      Cursor fila = bd.rawQuery(query, null);

      if (fila.moveToFirst()) {
        entidad = new clsUsuario();
        entidad.setInt_id_usuario(fila.getInt(0));
        entidad.setStr_nombres(fila.getString(1));
        entidad.setStr_apellido_paterno(fila.getString(2));
        entidad.setStr_apellido_materno(fila.getString(3));
        entidad.setStr_usuario(fila.getString(4));
        entidad.setStr_clave(fila.getString(5));
        entidad.setStr_email(fila.getString(6));
        entidad.setStr_dni(fila.getString(7));
        entidad.setStr_telefono(fila.getString(8));
        entidad.setStr_direccion(fila.getString(9));
        if (fila.getInt(10) == 1) entidad.setBol_sexo(true);
        else entidad.setBol_sexo(false);

        entidad.setByte_foto(fila.getBlob(11));
        entidad.setInt_id_persona(fila.getInt(12));
      }
    }
    bd.close();
    return entidad;
  }