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);