Mad 3.4
Mad 3.4
Experiment 3.4
2. Objective:
The objective of an Android application using Fragments can be is to
register user in the mobile application and store the data in the user details
in the database table using the SQLite database services provided by the
android device which can be saved locally.
3. Code:
<RelativeLayout 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:background="@drawable/backwelcome"
tools:context=".Home">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
android:layout_marginTop="90dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:columnCount="2"
android:rowCount="2">
<androidx.cardview.widget.CardView
android:id="@+id/myprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
android:layout_margin="10dp"
app:cardBackgroundColor="@color/peachDark"
app:cardCornerRadius="20dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/user64" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Profile"
android:textSize="20sp"
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
android:textAlignment="center"
android:textColor="@color/black"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
package com.example.workconnect;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String qry1 = "create table users(username text, email text, password text)";
sqLiteDatabase.execSQL(qry1);
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
4. Output:
5. Learning Outcomes:
1. How to use database in Java
2. How to work with android_main.xml file
3. How to use SQLite and SQLiteOpenHelper in Android Development.