Beispiel #1
0
    public boolean verificaUsuario(String email, String senha)
    {
        try
        {
            //Consulta o webservice para ver se o usuario existe
            JSONObject jsonRootObject = new JSONObject("http://localhost/gymup/usuarios/login/"+email+"/"+this.gerarHashMD5(senha));

            //Verifica se retornou o nome do usuario
            JSONArray jsonArray = jsonRootObject.optJSONArray("usuario");

            if (jsonArray.length() > 0)
            {
                //Iterate the jsonArray and print the info of JSONObjects
                for(int i=0; i < jsonArray.length(); i++)
                {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);

                    int codigoPessoa = Integer.parseInt(jsonObject.optString("codigoPessoa").toString());
                    String nomePessoa = jsonObject.optString("nomePessoa").toString();
                }


            }

            String[] campos = {this.EMAIL_PESSOA, this.SENHA_PESSOA, this.ATIVO_PESSOA};
            String where = this.EMAIL_PESSOA + " = '" + email + "' AND " + this.SENHA_PESSOA + " = '" + senha + "' AND "
                    + this.ATIVO_PESSOA + " =  'S'";

            db = banco.getReadableDatabase();
            cursor = db.query(this.TABELA, campos, where, null, null, null, null);

            //db.insert(this.TABELA, campos, where);

            if (cursor != null)
            {
                Log.i("dataops_", "Error :: Quant. retornada :: " + cursor.getCount()); //Print

                if (cursor.getCount() > 0)
                {
                    return true;
                }
            }

            cursor.close();
            db.close();*/
        }
Beispiel #2
0
 public Pessoa(Context context) {
     //Verifica  se o banco exites
     banco = new Banco(context);
     banco.getDatabase();
 }