lundi 15 juin 2015

SQLite on Android return wrong result

I'm having some troubles querying my SQLite DB from my Android APP.

This is the table I'm querying:

id | customerCode | invoiceNumber | openAmount | grossAmount

and this are the datas:

1 | 1 | 1 | -1.00 | -1.00
2 | 1 | 1 | 1.00 | 1.00
3 | 1 | 1 | 10.00 | 10.00
4 | 1 | 2 | 0.00 | 20.00
5 | 1 | 3 | 0.00 | 30.00

I'm trying to fetch only the lines which have openAmount != "0.00" and the query is:

String whereClause = MyTable.CUSTOMER_CODE + " = ? "
                + "and " + MyTable.OPEN_AMOUNT + " != \"0.00\"";

Cursor cur = mDb.query(MyTable.TABLE, null, whereClause, new String[]{customerId}, null, null, null);

The result I expect is that the query fetch the first 3 lines from my table, and this is the result I obtain if I query the DB from an external application (like SQLite Magic).

BUT... when I run the query from my Application, I obtain only the line with openAmount = -1.00.

I've tried a lot of solutions, like changing the where condition to fetch all the lines, but it seems that querying from my App not reads line 2 and 3.

I can't figure out a solution. A little help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire