dimanche 4 janvier 2015

Else part of if else statement not working

In two of my activities, else part of if else statement is not working.Each if else statement is used in button click.if part is working fine.


if else statement in Login.java



btn1.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {


// TODO Auto-generated method stub

String usr=edt1.getText().toString();
String pwd=edt2.getText().toString();
Cursor cur=mydb.rawQuery("select * from contacts where uname='"+usr+"'",null);
while (cur.moveToNext())
{
String pas=cur.getString(cur.getColumnIndex("pass"));

if (pwd.equals(pas))
{
Intent in=new Intent(getApplicationContext(),product_display.class);

startActivity(in);
}
else
{

Toast.makeText(login.this,"invalid username or password",Toast.LENGTH_SHORT).show();
}
}


});

}


if else statement in Product_dtl.java



if (nm.equals(prdname))
{
add2cart.setText("Already in Cart");
}
else {
mydb.execSQL("INSERT INTO add2cart (pnme,prate)VALUES('"+nm+"','"+prprice+"')");
Toast.makeText(getApplicationContext(),"add to cart",Toast.LENGTH_SHORT).show();
Intent in=new Intent(Product_Details.this,add2cart.class);
startActivity(in);
}

Aucun commentaire:

Enregistrer un commentaire