Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EditText korisnicko = (EditText)findViewById(R.id.editText1);
- EditText password = (EditText)findViewById(R.id.editText3);
- String username = ""+korisnicko.getText().toString();
- String passw = ""+password.getText().toString();
- boolean logInSuc=false;
- int id= 0;
- try {
- myDB = this.openOrCreateDatabase("korisnici", MODE_PRIVATE, null);
- Cursor c = myDB.rawQuery("SELECT * FROM kor WHERE username ='"+username+"' AND pass='"+passw+"'", null);
- c.moveToFirst();
- if (c.getCount()>0) {
- logInSuc=true;
- id = c.getInt(c.getColumnIndex("id"));
- }
- }
- catch(Exception e) {
- Log.e("Error", "Error", e);
- } finally {
- if (myDB != null) myDB.close();
- }
- if(logInSuc)
- {
- Intent i = new Intent(MainActivity.this, Activity1.class);
- i.putExtra("id", id);
- startActivity(i);
- }
- else
- Toast.makeText(view.getContext(), "Krivo korisničko ime ili lozinka", Toast.LENGTH_SHORT).show();
- logInSuc = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement