I'm using while loop and inside am using two if statements.
while(cr.moveToNext()){ if(cr.getCount() > 0){ if((cr.getString(5).equals(username)) && cr.getString(6).equals(password) && cr.getString(14).equals("success")) { String un = cr.getString(2); String uc = cr.getString(1); String rc = cr.getString(4); ...................... Toast.makeText(LoginActivity.this, "Successfully Logged In", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getApplicationContext(), Dashboard.class); startActivity(intent); } else{ Toast.makeText(LoginActivity.this, "Invalid Login", Toast.LENGTH_SHORT).show(); } } }
In this scenario, if I passed wrong value "Invalid Login" is executing many times [as it is inside while loop] and If I pass correct values both successfully login and Invalid login message is showing. How to make if condition to be properly work in this type of scenario...
https://stackoverflow.com/questions/67443476/while-loop-inside-multiple-if-condition-in-android-studio May 08, 2021 at 10:14AM
没有评论:
发表评论