Answer the question
In order to leave comments, you need to log in
How to make this code work, comparing strings and switching to the second android activity?
There is a DB in which the password is stored in open form and there is a text field.
I'm doing a case-insensitive comparison (There are only numeric values)
If you make comparisons and display its result, then everything works with a bang.
And to make it so that, with a positive result, switching to a new activity does not even compile.
What is the error is not clear (
There is a code:
public void OnClick_One (View view) {
ExternalDbOpenHelper dbOpenHelper = new ExternalDbOpenHelper(this, DB_NAME);
database = dbOpenHelper.getWritableDatabase();
Cursor passwordCursor = database.query(TABLE_NAME,
new String[]{PASS_ID, PASS_NAME},
null, null, null, null,
PASS_NAME);
passwordCursor.moveToFirst();
String pass = passwordCursor.getString(1);
String EdText_Pass = EdText_EnterPassword.getText().toString();
if(pass.equalsIgnoreCase(EdText_Pass))
//TextView_EnterPassword.setText("Строки совпадают");
Intent intent = new Intent(this, EnginesSettingsActivity.class);
startActivity(intent);
else
TextView_EnterPassword.setText("Строки не совпадают");
passwordCursor.close();
}
Answer the question
In order to leave comments, you need to log in
Syntax error, one expression can be used without parentheses.
if () {
Intent int = new Intent();
startActivity(int);
} else {
//do something
}
And also explain to me why this null is needed
new String[]{PASS_ID, PASS_NAME},
null, null, null, null,
PASS_NAME);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question