java - Storing user credential data - on device & online -
i writing android application requires user create account , login in order access data pulled external source (and locally on device). trying write register code , stuck on best approach use.
at moment, thinking should creating shared preferences store username , password on device , writing data external source via db call.
so want workflow this:
- user opens application on device
- user presented splashscreen "login" , "register" buttons.
- user selects "register" , enters basic info (name,email,preferred username,password)
- user clicks register button
- onclick creates shared preference , connects db write user credentials.
- user re-directed main activity
- user closes app
- user opens app , automatically logged application.
at moment have 2 classes, register.java contains ui , accountpreferences.java contains logic. best approach?
also, creating shared preferences , creating separate db call here best solution? tried looking accountmanager found ridiculously complicated. want make sure code right first time without having re-write if there better way of doing this.
thanks in advance,
scott.
your workflow not bad, make following changes:
- after register, redirect login activity instead main activity
- in login activity when login button clicked, check if username , password match. if matched save them sharedpreferences , move main activity. if not matched, show warning , clear username , password fields.
- sharedpreferences whilst being best option storing preferences, better weight out security issues. read this answer more details.
note: kind of questions frowned upon in so, because opinions based.
Comments
Post a Comment