Skip to content

Commit

Permalink
file added
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul255 committed Jul 11, 2019
1 parent ba3c121 commit 2814e6f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions LoginApplication/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HomeActivity"></activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public DatabaseHelper(Context context) {

@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE registeruser (ID INTERGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT)");
sqLiteDatabase.execSQL("CREATE TABLE registeruser (ID INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT)");

}

Expand All @@ -31,8 +31,8 @@ public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}

public long addUser(String user,String password){
SQLiteDatabase db=this.getWritableDatabase();
ContentValues contentValues=new ContentValues();
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("username",user);
contentValues.put("password",password);
long res = db.insert("registeruser",null,contentValues);
Expand All @@ -44,7 +44,7 @@ public boolean checkUser(String username, String password){
SQLiteDatabase db=this.getReadableDatabase();
String selection = COL_2 + "=?" + "and" + COL_3 + "=?";
String[] selectionArgs = {username, password };
Cursor cursor = db.query(TABLE_NAME,columns,selection,selectionArgs,null,null,null);
Cursor cursor = db.query(TABLE_NAME, columns, selection, selectionArgs, null, null, null);
int count = cursor.getCount();
cursor.close();
db.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.loginapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class HomeActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public void onClick(View view) {
String pwd = mTextPassword.getText().toString().trim();
Boolean res = db.checkUser(user,pwd);
if(res == true){
Toast.makeText( MainActivity.this,"Successfully Logged In",Toast.LENGTH_SHORT).show();
Intent LoginScreen = new Intent(MainActivity.this,HomeActivity.class);
startActivity(LoginScreen);
}
else{
Toast.makeText( MainActivity.this,"Login Error",Toast.LENGTH_SHORT).show();
Expand Down
20 changes: 20 additions & 0 deletions LoginApplication/app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
tools:context=".HomeActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome_user"
android:id="@+id/textView"
android:textColor="#123456"
android:textSize="50dp"
android:textStyle="bold"/>

</LinearLayout>
1 change: 1 addition & 0 deletions LoginApplication/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">LoginApplication</string>
<string name="already_registered">Already Registered?</string>
<string name="login">Login</string>
<string name="welcome_user">Welcome User</string>
</resources>

0 comments on commit 2814e6f

Please sign in to comment.