Advertisement
Guest User

Untitled

a guest
May 4th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. EditText korisnicko = (EditText)findViewById(R.id.editText1);
  2.         EditText password = (EditText)findViewById(R.id.editText3);
  3.  
  4.  
  5.         String username = ""+korisnicko.getText().toString();
  6.         String passw = ""+password.getText().toString();
  7.  
  8.  
  9.         boolean logInSuc=false;
  10.         int id= 0;
  11.         try {
  12.             myDB = this.openOrCreateDatabase("korisnici", MODE_PRIVATE, null);
  13.             Cursor c = myDB.rawQuery("SELECT * FROM kor WHERE username ='"+username+"' AND pass='"+passw+"'", null);
  14.             c.moveToFirst();
  15.             if (c.getCount()>0) {
  16.                 logInSuc=true;
  17.                 id = c.getInt(c.getColumnIndex("id"));
  18.             }
  19.         }
  20.         catch(Exception e) {
  21.             Log.e("Error", "Error", e);
  22.         } finally {
  23.             if (myDB != null) myDB.close();
  24.         }
  25.         if(logInSuc)
  26.         {
  27.             Intent i = new Intent(MainActivity.this, Activity1.class);
  28.             i.putExtra("id", id);
  29.             startActivity(i);
  30.         }
  31.         else
  32.             Toast.makeText(view.getContext(), "Krivo korisničko ime ili lozinka", Toast.LENGTH_SHORT).show();
  33.         logInSuc = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement