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:

  1. user opens application on device
  2. user presented splashscreen "login" , "register" buttons.
  3. user selects "register" , enters basic info (name,email,preferred username,password)
  4. user clicks register button
  5. onclick creates shared preference , connects db write user credentials.
  6. user re-directed main activity
  7. user closes app
  8. 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:

  1. after register, redirect login activity instead main activity
  2. 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.
  3. 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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -