0

I have a website and my visitors can register and they can use their username and password to login to their account.

My website is based on asp.net MVC and Microsoft SQL Server.

I want to develop an android app for my website.

On this scenario user can register and login to their account from this android app too.

I 'm new on android studio but I know that I should have a web service on my server side to use it on my app to handle some works like registering, login ,...etc.

I don't know how to store member's login information after they entered their username and password on my app on phone.

What is the best option on my case?

1- Account Authenticator like this post

2- Shared Preference like this post

3- Store authentication info on SQL Light (manually)

motevalizadeh
  • 5,244
  • 14
  • 61
  • 108
  • You shouldn't store credentials anywhere on the device. Only save a "logged-in" state. If necessary, maybe just a username. – OneCricketeer Aug 09 '16 at 19:41
  • Possible duplicate of http://stackoverflow.com/questions/1968416/how-to-do-http-authentication-in-android – OneCricketeer Aug 09 '16 at 19:46
  • @you mean on every activity creation i should check the member authentication on the server side? – motevalizadeh Aug 09 '16 at 19:46
  • Not quite... You lock out a user from accessing any part of the app until they login/register. Call this the "MainActivity", if you will. At the start of all your other activities, you should maintain a "isLoggedIn" value. If that is false, kick back to the login page and finish all other activities in the app. – OneCricketeer Aug 09 '16 at 19:48

1 Answers1

1

You can post user data (username/password) to your web-service and check username and password server side, if user data is correct, generate a token for user and store it on database and return generated token on web-service response (in json format) and get token and store it on the device (Shared Preferences). after that read and send user token on other web-services that need user authentication like get profile, edit profile , ...

Milad Nouri
  • 1,587
  • 1
  • 21
  • 32