I am working on a project where we want the user to be able to add a 4 digit pin. I want to be able to save it and have the app check upon launch that a pin is set, so that it asks the user for the pin if set or if not set just launch the app. I cannot save this pin in shared preference.
What would be the correct procedure to get this functionality? I will also be adding fingerprint scanner down the line so I need to make sure it works with that.
2
Answers
You can simply do that through Shared Preference also . Get a activity for Set password , make it Default activity . Application will be launch and ask to set password , if user set password then store it through Shared preference and forward them to Main Activity . And check saved password in SetPassword
onCreate(),onStart()
when it would be created next time .On the other hand in Main activity
onStart()
check thekey
also .Here i am sharing with some simple code –
SetPassword Class-
activity_set_password.xml
MainActivity class-
If you think about encryption also then you can check AES encryption .
Well you can use SharedPreferences or you can save your data Using normal java InputStream/OutputStream classes
-in case of shared prefs: you can see the link below
https://developer.android.com/training/data-storage/shared-preferences
-in case of java native classes you can access the link below
https://www.tutorialspoint.com/javaexamples/file_write.htm