I am working on an android app. there is a table that has the following schema
question_link String
answer_link String
field_link String
I am working with the database with content provider
if the data for the table (for each row: question_link then answer_link then field_link) is:
- car ___ bus ___auto
- truck ___bike ___auto
- car ___bike ___auto
when I run the following code:
Cursor cursor1 = contentResolver.query(uri,
new String[]{question_link},
question_link + " = ? " ,
new String[]{"car"},
null);
int c1 = cursor1.getCount(); // the c1 becomes 2
Cursor cursor2 = contentResolver.query(uri,
new String[]{answer_link},
answer_link + " = ? " ,
new String[]{"bike"},
null);
int c2 = cursor2.getCount(); // the c2 becomes 1
There is 2 "car" in the question_link column and there is 2 "bike" in the answer_link column. why cursor1 its count is 2 and cursor2 its count is 1? if I run the following code which I query answer_link first:
Cursor cursor1 = contentResolver.query(uri,
new String[]{answer_link},
answer_link + " = ? " ,
new String[]{"bike"},
null);
int c1 = cursor1.getCount(); // the c1 becomes 2
Cursor cursor2 = contentResolver.query(uri,
new String[]{question_link},
question_link + " = ? " ,
new String[]{"car"},
null);
int c2 = cursor2.getCount(); // the c2 becomes 1
The data is a same, how the order make a difference? I do not understand. what is the problem? and how can I solve it?
Aucun commentaire:
Enregistrer un commentaire