I am writing an android application that requires the user to create an account and then login in order to access data pulled from an external source (and locally on device). I am trying to write the register code and am stuck on what the best approach to use.
At the moment, I am thinking I should be creating shared preferences to store the username and password on the device and then writing the data to an external source via a db call.
So what i want the workflow to look like is this:
- User opens application on device
- User is presented with splashscreen with "Login" and "Register" buttons.
- User selects "Register" and enters basic info (name,email,preferred username,password)
- User clicks Register button
- OnClick creates the shared preference and connects to the db to write the user credentials.
- User is re-directed to the main activity
- User closes app
- User opens app and is automatically logged into application.
At the moment I have 2 classes, a register.java that contains the UI and an AccountPreferences.java that contains the logic. Is this the best approach?
Also, is creating shared preferences and then creating a separate db call here the best solution? I tried looking into AccountManager but found this ridiculously complicated. I want to make sure I code it right the first time without having to re-write if there is a better way of doing this.
Thanks in advance,
Scott.