Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Problema com Where com valor numérico

Não, Cleber. A conversão já aconteceu em uma etapa anterior, como indica o trecho new String[] { precoAux } (precoAux já é uma String).

Mas eu estava errado. Achei que essa API poderia receber primitivos, mas me enganei, ela recebe só Strings mesmo.


Em seg, 9 de fev de 2015 18:00, Cleber - Android Developer <clebaori@gmail.com> escreveu:

quando for utilizar numeros utilize o String.valueof().
Pelo que analisei o problema ocorre no bindAllArgsAsStrings que chama bindString, ou seja espera um objeto do tipo String, logo se você passar um objeto primitivo (int, double, float) vai dar pau. (me corrijam se eu estiver enganado).

Exemplo

new String[] { String.valueof(precoAux) }

Em 9 de fevereiro de 2015 17:23, Jonas Alves <jonasfa@gmail.com> escreveu:

Faz tempo que não uso essa API, mas acho que você não deveria fazer cast do precoAux pra String se vai comparar ele com números.


Em seg, 9 de fev de 2015 17:17, Gorio <goriofab@gmail.com> escreveu:

c = mDb.query(Produtos.TABELA, new String[] { Produtos.CODIGO }, Produtos.VALOR_UNIT + " = ? and " + Produtos.SEMIJOIA + " = 'S'",
                    new String[] { precoAux },
                    null, null,
                    Produtos.REFERENCIA
            );

Atenciosamente

Gorio
(www.gorio.eng.br)

 


Em 9 de fevereiro de 2015 17:16, Gorio <goriofab@gmail.com> escreveu:

Tente isso

db.query(Produtos.TABELA, new String[] { Produtos.CODIGO }, Produtos.VALOR_UNIT + " = ? and " + Produtos.SEMIJOIA + " = 'S'",
                    new String[] { precoAux },
                    null, null,
                    Produtos.REFERENCIA
            );

Atenciosamente

Gorio
(www.gorio.eng.br)

 


Em 9 de fevereiro de 2015 17:08, Felipe Aron <felipearon@gmail.com> escreveu:

Galera tenho a seguinte Query:

                      c = mDb.query(Produtos.TABELA,
new String[] { Produtos.CODIGO },
Produtos.VALOR_UNIT.concat("=?")
.concat(" and " + Produtos.SEMIJOIA.concat("='S'")),
new String[] { precoAux },
null, null,
Produtos.REFERENCIA
);

Estou usando a condição "=" (igual) ao valor inidicado. Ex.> 21.90

Ele não me retorna nada! :(

Mas se usar ">=" ele me retorna os produtos com valor de 21.90 além dos de maior valor.

Porque o "=" não funciona nesse caso?

--
Programador

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário