Reputation: 21
Forgive me in advance but I've read all topics related to this and this newbie is still confused. Let me start my giving a brief run-down of what I'm trying to achieve... I've created a quiz. Since I'm adding a leaderboard I require a user to create a username and a password or email address so as to be unique. I've managed to create register and login functions using phpmysql and it all works beautifully in my app. However, I don't wish the user to have to login in each time the app is opened but rather it remember the user details. Do I use the account manager function in the android sdk and scrap the mysql? Or should I just modify what I already have? Do I even need to use phpmysql for a login? I realise I will have to use it for the leaderboard. Any help to point me in the right direction would be much appreciated.
Cheers
Upvotes: 2
Views: 1555
Reputation: 3929
Even though Robbies answer is great, It sounds like an overkill for your application, at least in short term. An easier solution would be to save a boolean with Shared Preferences each session:
http://developer.android.com/guide/topics/data/data-storage.html#pref
Shared Preferences stores variables betweens sessions and are simple to fetch. In your case you would save a boolean true if a login was sucessful. Next time the application is started, fetch the boolean and if true, login is'nt needed. If there are no such variable or if it is set to false(previous login failed/user logout), demand login!
Good luck
Upvotes: 0
Reputation: 17710
Us a session system, similar to how you'd use cookies.
When the android device connects, in PHP:
In Android:
For subsequent calls:
When the user "logs on"
As the file storage is persisent, even when the app closes, and the phone ID won't change, PHP will always know who the user is on connection, even after the app is closed.
Upvotes: 3