public void Login(View v) {
   String user = getStringFromSharedPreferences("User");
   String password = getStringFromSharedPreferences("Password");
   if (db.validateUser(user, password)) {
     prefs.edit().putBoolean("logged", true).apply();
     Intent i = new Intent(this, MainActivity.class);
     startActivity(i);
     finish();
   } else {
     showToast("Username o password incorrecte");
   }
 }
 public void Register(View v) {
   String user = getStringFromSharedPreferences("User");
   String password = getStringFromSharedPreferences("Password");
   db.addUserToDB(user, password);
 }
 @Override
 protected void onDestroy() {
   super.onDestroy();
   db.closeDB();
 }