示例#1
0
  public String mensaje(String organo) {

    String cad = "";
    int numAleatorio;
    if (organo.equalsIgnoreCase("General")) {
      numAleatorio = aleatorio(6);
    } else {
      numAleatorio = aleatorio(2);
    }

    try {
      aBD = new Ayudante(this, "mensajes", null, 1);
      db = aBD.getReadableDatabase();
      if (db != null) {
        Cursor cursor =
            db.rawQuery(
                "SELECT * FROM mensajes where tematica='" + organo + "' and  num=" + numAleatorio,
                null); // +i+" and num="+g,null);//+num+" and num="+numAleatorio+"",null);
        int numcol = cursor.getColumnCount();
        int numren = cursor.getCount();
        while (cursor.moveToNext()) {
          cad = cursor.getString(2);
        } // while
        // Toast.makeText(getApplicationContext(),"es "+numAleatorio,Toast.LENGTH_SHORT).show();

        cursor.close();
        db.close();
      } // if
      else cad = "db fue null";
    } // try
    catch (Exception e) {
      String cad2 = "ERROR " + e.getMessage();
    } // catch
    return cad;
  }