Reputation: 11
CHandler handler=new CHandler(getApplicationContext());
Cursor C=handler.returnc(name);
if(C!=null)
{
C.moveToPosition(1);
String me="me";
while(C.moveToNext())
{
String content=C.getString(0);
String sender=C.getString(1);
if(C.getString(1)==me)
{
Toast.makeText(getApplicationContext(), sender, Toast.LENGTH_LONG).show();
}
Handler query
public Cursor returnc(String abc)
{
SQLiteDatabase db=this.getWritableDatabase();
return db.query(TABLE_a, new String[]{KEY_CONTENT,KEY_FROM}, KEY_ac+"=?", new String[] { String.valueOf(abc) },null, null,null);
}
The query at position 1 is returning me but then too the if condition in the grabber is not getting out to be true that is
if(sender=="me")
I am not getting the reason behind that what could be the reason...
Upvotes: 0
Views: 40
Reputation: 1973
C.getString(1)==me should be C.getString(1).equals(me). You want to compare the values of the two strings, not that they are the same object, right?
Upvotes: 1