android - How to dispaly incoorect Login toast validation -
in login form check username , password in database values,if correct show toast "welcome" , if wrong show toast "incorrect".but in coding if password wrong both toast display.
and if database null means type of condition makes toast
i'm new android,i know it's simple question, tried lot.help me please
signin.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub database db=new database(sin.this); sqlitedatabase sb=db.getwritabledatabase(); cursor c=sb.rawquery("select * newuser",null); c.movetofirst(); for(int i=0;i<c.getcount();i++) { if((c.getstring(1).tostring().equalsignorecase(un.gettext().tostring()))&&(c.getstring(3).tostring().equalsignorecase(pass.gettext().tostring()))) { toast.maketext(sin.this, "welcome "+c.getstring(0),toast.length_long).show(); finish(); intent in=new intent(sin.this,mainactivity.class); startactivity(in); } else { toast.maketext(sin.this, "invalid credentials",toast.length_short).show(); } c.movetonext(); } } });
your basic problem in query
string username = un.gettext().tostring(); string pwd = pass.gettext().tostring(); string query="select * newuser username = "+"'"+ username+"'"+" , "+"password="+"'"+pwd+"'"; cursor c=sb.rawquery(query,null); if(c.getcount()>0) { toast.maketext(sin.this, "welcome "+c.getstring(0),toast.length_long).show(); finish(); intent in=new intent(sin.this,mainactivity.class); startactivity(in); } else toast.maketext(sin.this, "invalid credentials",toast.length_short).show();
Comments
Post a Comment