Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void loginTheUser(){
- loginuser.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- etCategory =(EditText)findViewById(R.id.editTextCategory);
- etName =(EditText)findViewById(R.id.editTextUserName);
- etPassword =(EditText)findViewById(R.id.editTextUserPassword);
- String name = etName.getText().toString();
- String pass = etPassword.getText().toString();
- String cat = etCategory.getText().toString();
- cursor = db.rawQuery("SELECT * FROM " + DbHelper.TABLE_USER + "WHERE " + DbHelper.COL_USERNAME + "=? AND " + DbHelper.COL_USERPASS + "=? AND " + DbHelper.COL_USERCAT + "=?", new String[]{name, pass, cat});
- if (cursor != null) {
- if (cursor.getCount() > 0) {
- Toast.makeText(MainActivity.this, "Login Success", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(MainActivity.this, "Login error", Toast.LENGTH_SHORT).show();
- }
- }
- }
- });
- }
- Button buttonLogin,loginuser;
- EditText etName, etPassword, etCategory;
- DbHelper dbHelper;
- SQLiteDatabase db;
- SQLiteOpenHelper openHelper;
- Cursor cursor;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- openHelper=new DbHelper(this);
- db = openHelper.getReadableDatabase();
- //db = openHelper.getWritableDatabase();
- buttonLogin = (Button)findViewById(R.id.btnLogin);
- loginuser = (Button)findViewById(R.id.buttonlogging);
- //etCategory =(EditText)findViewById(R.id.editTextCategory);
- //etName =(EditText)findViewById(R.id.editTextUserName);
- //etPassword =(EditText)findViewById(R.id.editTextUserPassword);
- loginTheUser();
- }
Add Comment
Please, Sign In to add comment