这是为什么是假?我无法得到它。 DataBaseHelper.getBoolean();是一个字符串值。在这个if语句中,它输出相同的结果,但它表示它不相等。我没有得到什么。 String == String False
String a = DataBaseHelper.getBoolean(id);
String b = DataBaseHelper.getBoolean(id);
if (a==b){
newTextView.setText(DataBaseHelper.getBoolean(id) + " == " + DataBaseHelper.getBoolean(id) + " is TRUE \n");
} else {
newTextView.setText(DataBaseHelper.getBoolean(id) + " == " + DataBaseHelper.getBoolean(id) + " is FALSE \n");
}
从toher类的getBoolean方法。
public String getBoolean(int randomIndex) {
// TODO Auto-generated method stub
open();
Cursor c = myDataBase.query(TABLE_NAME1, columns, WHATTODONOW_COLUMN_ID
+ "=" + randomIndex, null, null, null, null);
if (c != null) {
c.moveToFirst();
String text = c.getString(8);
return text;
}
closee();
return null;
}
使用'=='比较字符串值将不起作用,请使用equals()方法。 – Geros
尝试先搜索你的问题,然后问:) –