Skip to content

Commit 896e75b

Browse files
Add files via upload
1 parent f18f64d commit 896e75b

File tree

76 files changed

+2014
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2014
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugins {
2+
id("com.android.application")
3+
}
4+
5+
android {
6+
namespace = "com.example.registrationdatabase"
7+
compileSdk = 34
8+
9+
defaultConfig {
10+
applicationId = "com.example.registrationdatabase"
11+
minSdk = 24
12+
targetSdk = 34
13+
versionCode = 1
14+
versionName = "1.0"
15+
16+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
isMinifyEnabled = false
22+
proguardFiles(
23+
getDefaultProguardFile("proguard-android-optimize.txt"),
24+
"proguard-rules.pro"
25+
)
26+
}
27+
}
28+
compileOptions {
29+
sourceCompatibility = JavaVersion.VERSION_1_8
30+
targetCompatibility = JavaVersion.VERSION_1_8
31+
}
32+
}
33+
34+
dependencies {
35+
36+
implementation("androidx.appcompat:appcompat:1.6.1")
37+
implementation("com.google.android.material:material:1.10.0")
38+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
39+
testImplementation("junit:junit:4.13.2")
40+
androidTestImplementation("androidx.test.ext:junit:1.1.5")
41+
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
42+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.registrationdatabase;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.example.registrationdatabase", appContext.getPackageName());
25+
}
26+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.RegistrationDatabase"
14+
tools:targetApi="31">
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
<meta-data
25+
android:name="preloaded_fonts"
26+
android:resource="@array/preloaded_fonts" />
27+
</application>
28+
29+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.example.registrationdatabase;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
import android.view.View;
6+
import android.widget.Button;
7+
import android.widget.EditText;
8+
import android.widget.RadioButton;
9+
import android.widget.RadioGroup;
10+
import android.widget.TextView;
11+
import android.widget.Toast;
12+
13+
public class MainActivity extends AppCompatActivity {
14+
RegistrationDatabase rdb;
15+
EditText id, name, rollNo, section;
16+
Button submit, delete, display;
17+
TextView displaydb;
18+
RadioGroup radioGroup;
19+
RadioButton maleButton, femaleButton;
20+
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
24+
setContentView(R.layout.activity_main);
25+
id = findViewById(R.id.id);
26+
name = findViewById(R.id.name);
27+
rollNo = findViewById(R.id.rollNo);
28+
section = findViewById(R.id.section);
29+
displaydb = findViewById(R.id.displaydb);
30+
submit = findViewById(R.id.submit);
31+
delete = findViewById(R.id.delete);
32+
display = findViewById(R.id.display);
33+
radioGroup = findViewById(R.id.radioGroup);
34+
maleButton = findViewById(R.id.maleButton);
35+
femaleButton = findViewById(R.id.femaleButton);
36+
rdb = new RegistrationDatabase(getApplicationContext(),"REGISTRATION",null,1);
37+
38+
}
39+
40+
public void submit(View view) {
41+
String id1 = id.getText().toString();
42+
String name1 = name.getText().toString();
43+
String rollNo1 = rollNo.getText().toString();
44+
String section1 = section.getText().toString();
45+
rdb.insertValues(id1,name1,rollNo1,section1);
46+
47+
Toast.makeText(getApplicationContext(),"Submitted",Toast.LENGTH_LONG).show();
48+
49+
}
50+
51+
public void delete(View view) {
52+
String idD = id.getText().toString();
53+
rdb.deleteValues(idD);
54+
Toast.makeText(getApplicationContext(),"Deleted",Toast.LENGTH_LONG).show();
55+
}
56+
57+
public void display(View view) {
58+
String tableData1 = rdb.displayDatabase();
59+
displaydb.setText(tableData1);
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.example.registrationdatabase;
2+
3+
import android.content.Context;
4+
import android.database.Cursor;
5+
import android.database.sqlite.SQLiteDatabase;
6+
import android.database.sqlite.SQLiteOpenHelper;
7+
import android.view.View;
8+
9+
import androidx.annotation.Nullable;
10+
11+
public class RegistrationDatabase extends SQLiteOpenHelper {
12+
public RegistrationDatabase (@Nullable Context context,@Nullable String name,@Nullable SQLiteDatabase.CursorFactory factory, int version){
13+
super(context,name,factory,version);
14+
15+
}
16+
17+
@Override
18+
public void onCreate(SQLiteDatabase sqLiteDatabase) {
19+
// SQLiteDatabase sqldb = this.getWritableDatabase();
20+
sqLiteDatabase.execSQL("CREATE TABLE REGISTRATION (id VARCHAR(20),name VARCHAR(20),rollNo VARCHAR(20)," +
21+
"section VARCHAR(20))");
22+
23+
24+
}
25+
26+
@Override
27+
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
28+
29+
}
30+
public void insertValues(String id, String name, String rollNo, String section){
31+
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
32+
sqLiteDatabase.execSQL("INSERT INTO REGISTRATION VALUES(?,?,?,?)",new String[]{id,name,rollNo,section});
33+
// sqLiteDatabase.close();
34+
}
35+
public void deleteValues(String id){
36+
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
37+
sqLiteDatabase.delete("REGISTRATION","id = ?",new String[] {id});
38+
}
39+
public String displayDatabase(){
40+
String tableData = "";
41+
SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();
42+
Cursor cursor = sqLiteDatabase.rawQuery("SELECT * FROM REGISTRATION",null);
43+
while (cursor.moveToNext()){
44+
String id = cursor.getString(0);
45+
String name = cursor.getString(1);
46+
String rollNo = cursor.getString(2);
47+
String section = cursor.getString(3);
48+
tableData = "Id:"+id+"\n"+"Name:"+name+"\n"+"ROll no."+rollNo+"\n"+"Section:"+section+"\n";
49+
}
50+
// sqLiteDatabase.close();
51+
return tableData;
52+
}
53+
54+
}

0 commit comments

Comments
 (0)