I am a beginner in Android Development (using Java). I am trying to built an App with a single Login Activity Page where there are two types of users - 1. Normal User 2.An Admin . So depending on the user I want the Login Button to redirect them to their respective activity pages.
I have found 2 ways -
- By getting the input text from the Username edit text field in login page and using if else condition .
- Doing via querying the Database(MySQL & php)
Which of them would be a better choice ? And can anyone provide a code snippet for it ?
CodePudding user response:
According to me best way would be to add a user type in the user info table on the basis of which you can identify the user type on login form just by the response from the database
CodePudding user response:
It would be better to add RadioGroup for both Normal User and Admin as User can be Admin or Normal.
You can add RadioGroup with 2 Radio Buttons, so user can choose among them, This Way is better because you dont have to put extra load on your sever for Iterating among both.
Even better would be having different Tables for Normal users and Admin for quick responses.
You can follow this Medium Tutorial for Radio Buttons Android: Selection Controls