Tuesday 15 April 2014

android - Really weird result with a database query from my app (sqlite database - detailed code inside) -


Now I am experiencing strange problems with my application while populating a list view with results from the database.
To send me to my database, select two parameters : A category product (restaurant, store, etc.) and a payment option < / Strong> (card / cash).

When the user can choose, so it sets a string variable to a fixed interval ( Category intervals and pay gap ), such :

(this is the pop-up menu):

  case R.id.item11c: filterTitle = "bakery and pastry Stores "; Category interval = "('" + 86 + "', '" + 87 + "')"; FilterButton.setText ("bakery and pastry shops"); Back true;   

Payment options (this is a radio button):

  OnClickListener radiobutton_no_listener = new OnClickListener () {public Zero onClick (see V) {paymentInterval = "('" + "')"; }}; OnClickListener radiobutton_yes_listener = New OnClickListener () {Public Zero onClick (see v) {paymentInterval = "('' + 'Visa' + '', '' + 'Master' + '')"; }}; After that, when the user has clicked on the "OK" button on the button with his preference and alertness, then the query method  findFilterInTable ()  
 < Code> Public cursor findFilterInTable (string categoryInterval, string paymentInterval) {st Ring where = COL_CAT1 + + categoryInterval + "or" + COL_CAT2 + "to", "in" + CategoryInterval + "or" + COL_CAT3 + "" + class interval + "and" + COL_PAYMENT + "IN" + pay gap; c = myDatabase.query (DATABASE_TABLE, new String [] {KEY_ROWID, COL_NAME, COL_STREET, COL_WEBSITE, COL_PAYMENT, COL_TELEPHONE, COL_PRICE, COL_REMARKS, COL_DATEFRIENDLY}, where, null, null, null, null) cursor; Return c; }   

But it only works partially: it works perfectly well for the part of the class (in grade COL_CAT1 in class or COL_CAT2 ....) But for the part of the payment, I have a strange result. When I click on this button (payment by card), it receives some results from the list when I do not click, but it retrieves things that are not relevant to the research. Anything that I write in my pay-times ("Visa" or "Master" as well as "Okokinzfenso"), whatever it seems, just connects some elements into specific parts. For example, in this case, the element where CAT_3 = 87, which does not understand.
So the value of my payment affects the result in my findFilterInTable () method, but it also does not appear in the appropriate column (COL_PAYMENT) but COL_CAT1, COL_CAT2, COL_CAT3, and for some reason, remove some results.

I am really bothered with it and do not know how to solve a problem that I do not understand and I do not understand how to find a solution! Thanks for reading.

Change

  string where = COL_CAT1 + "" + category gaps + "Or" + + COL_CAT2 + "IN" + range interval + "or" + COL_CAT3 + "IN" + range interval + "and" + COL_PAYMENT + "IN + payment interval;  
 

To where string = "(" + COL_CAT1 + "IN + +" + + + + "or" + + COL_CAT2 + "IN + + + + range interval +" or "+ COL_CAT3 +" IN "+ range interval + ") And" + COL_PAYMENT + "IN" + Payment interval;

No comments:

Post a Comment