我正在从我的数据库中获取列值(工作正常),然后在循环时将这些值一次放入“字符串 X”中。在同一个循环中,我想将用户通过 UI 提供给我的值与 X 进行比较,并基于此比较,我希望 x 为真或假。但是 x 总是显示为真!这是我的代码:
private boolean fillData() {
Cursor c = DBHelper.fetchAllIDs();
// List<String> idList = new ArrayList<String>();
if (c.moveToFirst()) {
do {
String X = (c.getString(c.getColumnIndexOrThrow("IDno")));
Toast.makeText(getApplicationContext(), "" +X, Toast.LENGTH_LONG).show();
String B = null;
B = Idno.getText().toString();
if (B.equals(X));
{
Toast.makeText(getApplicationContext(), "If condition true"+B, Toast.LENGTH_LONG).show();
x=true;
}
} while (c.moveToNext());
}
return x;
}