SHARE
TWEET

Sqlite basic

a guest Aug 18th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.repoai.myhome;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.EditText;
  10.  
  11. import com.repoai.myhome.Rooms.RoomList;
  12. import com.repoai.myhome.Users.RegisterUser;
  13. import com.repoai.myhome.Users.UserAble;
  14. import com.repoai.myhome.Users.Users_SQLite;
  15. import com.repoai.myhome.Users.Users_sp;
  16. import com.sdsmdg.tastytoast.TastyToast;
  17.  
  18. public class MainActivity extends AppCompatActivity {
  19.     Context context;
  20.     UserAble users;
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_main);
  25.         setPointer();
  26.  
  27.     }
  28.  
  29.     private void setPointer() {
  30.         this.context = this;
  31.         //share prefernces
  32.         //users = Users_sp.getSharedInstance(context);
  33.  
  34.         //SQLite users
  35.         users = new Users_SQLite(context,null);
  36.  
  37.         final EditText txtLogin = findViewById(R.id.loginUserName);
  38.         final EditText txtPassword = findViewById(R.id.loginUserPass);
  39.         findViewById(R.id.loginBtnLogin).setOnClickListener(new View.OnClickListener() {
  40.             @Override
  41.             public void onClick(View view) {
  42.                 if (users.checkUser(txtLogin.getText().toString(),txtPassword.getText().toString())){
  43.                     Intent intent = new Intent(context, RoomList.class);
  44.                     intent.putExtra("userName",txtLogin.getText().toString());
  45.                     startActivity(intent);
  46.                     finish();
  47.                 } else {
  48.                     TastyToast.makeText(getApplicationContext(), "User not registred", TastyToast.LENGTH_LONG, TastyToast.ERROR);
  49.                 }
  50.             }
  51.         });
  52.         findViewById(R.id.loginBtnRegister).setOnClickListener(new View.OnClickListener() {
  53.             @Override
  54.             public void onClick(View view) {
  55.                 startActivity(new Intent(context, RegisterUser.class));
  56.             }
  57.         });
  58.     }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top