我想查询具有特定参考号+“ 0”或“ 3”的数据库。我的下面的代码返回奇怪的结果。什么是正确的查询方式?
MyBaseVoyageFragment.java
String broadcastTAG = BROADCAST_TAG + owner + String.valueOf(direction);
if (intent != null) { // put the receiving data on intent
Log.e("received", intent.getAction()); // succesfull action
String intentAction = intent.getAction();
if (intentAction.equals(broadcastTAG)) {
parseIntentDataAndLoadVoyagesAdapter = new ParseIntentDataAndLoadVoyagesAdapter(intent);
parseIntentDataAndLoadVoyagesAdapter.execute(""); // asenkron görevi çalıştır.
//loadVoyagesToAdapter();
} else if (intentAction.equals(BROADCAST_TAG + owner + "Error")) {
showLoadingDialog(false);
setErrorView(intent.getIntExtra("data", 0));
}
}
答案 0 :(得分:0)
您说的是特定的参考编号+“ 1”或“ 3”。但是,当您编写选择查询时,此处传递的是“ 0”而不是“ 1”
cursor = db.query(TABLE_PAPER, new String[] {KEY_PAPER_ID,
KEY_PAPER_AMOUNT,
KEY_PAPER_DATE,
KEY_PAPER_REFERENCE,
KEY_PAPER_PAID},KEY_PAPER_REFERENCE + "=?" + " AND " + KEY_PAPER_PAID + "=?" + " OR " + KEY_PAPER_PAID + "=?",
new String[]{String.valueOf(rowId), "1", "3"},
null, null, "date DESC");
您应在查询中传递“ 1”而不是“ 0”。