0% found this document useful (0 votes)
3 views7 pages

Student Login and Display System

The document contains the code for an Android application with two main activities. The first activity allows users to input their name and roll number, which are then stored in a SQLite database, while the second activity retrieves and displays the stored data. The layout files define the user interface elements for both activities, including EditTexts and Buttons for user interaction.

Uploaded by

lochansawant0107
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Student Login and Display System

The document contains the code for an Android application with two main activities. The first activity allows users to input their name and roll number, which are then stored in a SQLite database, while the second activity retrieves and displays the stored data. The layout files define the user interface elements for both activities, including EditTexts and Buttons for user interaction.

Uploaded by

lochansawant0107
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Activity_main.

xml
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="[Link]

xmlns:app="[Link]

xmlns:tools="[Link]

android:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity"

android:background="#A7D7EB">

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your name"

android:textSize="30dp"

android:textStyle="bold"

android:textColor="@color/black"

android:layout_marginTop="200dp"

android:layout_marginLeft="50dp"

android:id="@+id/edit"/>

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:hint="Enter your Roll no"

android:textSize="30dp"

android:textStyle="bold"

android:textColor="@color/black"
android:layout_marginTop="280dp"

android:layout_marginLeft="50dp"

android:id="@+id/text"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="login"

android:textSize="30dp"

android:textStyle="bold"

android:layout_marginTop="380dp"

android:layout_marginLeft="100dp"

android:id="@+id/but"/>

<Button

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="100dp"

android:layout_marginTop="460dp"

android:text="Display"

android:textSize="20dp"

android:id="@+id/but1"/>

</RelativeLayout>

Main_Activity.java
package [Link];

import [Link];
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link].*;

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity extends AppCompatActivity {

EditText edit;

EditText text;

Button but;

SQLiteDatabase DB;

Button but1;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main);

edit=findViewById([Link]);

text=findViewById([Link]);

but=findViewById([Link]);

but1=findViewById([Link].but1);

DB=openOrCreateDatabase("student",MODE_PRIVATE,null);
[Link]("CREATE TABLE IF NOT EXISTS student(rollno int,name text)");

[Link](new [Link]() {

@Override

public void onClick(View view) {

String name=[Link]().toString();

int roll=[Link]([Link]().toString());

ContentValues value=new ContentValues();

[Link]("rollno",roll);

[Link]("name",name);

[Link]("student",null,value);

[Link]([Link], "record inserted successfully!!!", Toast.LENGTH_SHORT).show();

});

[Link](new [Link]() {

@Override

public void onClick(View view) {

Intent obj=new Intent([Link],[Link]);

startActivity(obj);

});

Activity_main2.Xml
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="[Link]

xmlns:app="[Link]
xmlns:tools="[Link]

android:id="@+id/main"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity2"

android:background="@color/white">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text=".............................."

android:textSize="20dp"

android:layout_marginTop="200dp"

android:layout_marginLeft="100dp"

android:id="@+id/text1"

android:textColor="@color/black"/>

</RelativeLayout>

[Link]
package [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link].*;

import [Link];
import [Link];

import [Link];

import [Link];

import [Link];

public class MainActivity2 extends AppCompatActivity {

TextView text1;

SQLiteDatabase db;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main2);

text1=findViewById([Link].text1);

db=openOrCreateDatabase("student",MODE_PRIVATE,null);

Cursor cu=[Link]("SELECT *FROM student",null);

StringBuilder data=new StringBuilder();

while([Link]()){

int roll=[Link](0);

String name=[Link](1);

[Link]("Roll no").append(roll).append("Name").append(name).append("\n");

[Link]();

[Link](data);

You might also like