I am fetching column values from my DB (Which is working fine) then I am putting these values into ‘String X’ one at a time as it loops. In the same loop I want to compare the values supplied to me by the user through UI with X and based on this comparison I want x to be true or false. But x always shows true! Here is my code:
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;
}
I got this folks, I had mistakenly put a ‘;’ at the end of my if statement. Sorry! Silly!