forked from sambitmanna/Sambit-Manna
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResetPassword.java
More file actions
52 lines (39 loc) · 1.54 KB
/
ResetPassword.java
File metadata and controls
52 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.example.finaleapp;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class ResetPassword extends AppCompatActivity {
EditText username, newPassword;
Button resetBtn;
DatabaseHelper dbHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reset_password);
username = findViewById(R.id.resetUsername);
newPassword = findViewById(R.id.resetNewPassword);
resetBtn = findViewById(R.id.resetButton);
dbHelper = new DatabaseHelper(this);
resetBtn.setOnClickListener(v -> {
String user = username.getText().toString();
String pass = newPassword.getText().toString();
boolean success = dbHelper.updatePassword(user, pass);
if (success) {
Toast.makeText(this, "Password Reset Successful", Toast.LENGTH_SHORT).show();
startActivity(new Intent(this, MainActivity.class));
finish();
} else {
Toast.makeText(this, "Username not found", Toast.LENGTH_SHORT).show();
}
});
}
}