A real app emails a reset link, but a phone-only SQLite app has no server to send email. Instead, users choose a secret answer when they sign up, and must give it to reset their password. Without it, anyone could reset anyone's password just by knowing a username.
3. Store the answer safely
In DatabaseHelper, add an ANSWER_HASH column. Like the password, the answer is salted and hashed, never stored as typed. Answers are trimmed and lower-cased first, so "Green " and "green" match.
4. Ask for the answer at sign-up
In activity_register.xml, show the question as text and add an answer box below it. RegisterActivity passes the answer to insertData(user, pass, answer).
5. Add the link
On the login screen, add Forgot password? above the Login button. It opens ForgotPasswordActivity and passes along any username already typed.
6. Build the reset screen
activity_forgot_password.xml has the username, the question and answer, and the new password twice. It sits in a ScrollView, so it still fits on small phones with the keyboard open.
7. Check the answer, then save
resetPassword(username, answer, newPassword) finds the user, hashes the typed answer with their salt and compares. Only if it matches does it update the password hash. Doing both in one method means the password can't change without a correct answer.
8. Don't give hints
For an unknown username or a wrong answer, show the same message. Saying "no such user" would tell an attacker which usernames exist.
9. Make the passwords match
Before saving, compare the two new password boxes and show an error on the second if they differ.
10. Run it
Register with an answer, log out, tap Forgot password?, reset it, then log in with the new password.
Tidy layouts with styles
The input boxes, titles, buttons and links each have a style in themes.xml. Every layout uses them, so changing the amber colour or text size is one edit, not twenty.
What's improved over the video
A security answer protects the reset, answers and passwords are hashed, the error never reveals which usernames exist, the new password is typed twice, and the form scrolls on small screens.
Files affected
Check what to add and what to replace before copying code.