0% found this document useful (0 votes)
22 views25 pages

Attempt Any FIVE of The Following:: A) Define OHA and State Goal of OHA

Uploaded by

mh39gamerz
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)
22 views25 pages

Attempt Any FIVE of The Following:: A) Define OHA and State Goal of OHA

Uploaded by

mh39gamerz
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
You are on page 1/ 25

1. Attempt any FIVE of the following: 10 a) Define OHA and state goal of OHA.

b) Define Android Virtual


Devices (AVD). c) State how the APK files are built? d) Enlist the elements of UI. e) State the uses of Intent
in Android. f) Name any four methods to get location data in android. g) Explain significance of content
provider. 2. Attempt any THREE of the following: 12 a) Describe the different features of Android. b)
Explain features of Android SDK. c) Explain the Android security model. d) Elaborate the need of
permissions in Android. Explain the permissions to set system functionalities like SEND-SMS, bluetooth.
22617 Seat No. 12223 3 Hours / 70 Marks Downloaded by Prashant Gaikwad
([email protected]) lOMoARcPSD|25816107 22617 [ 2 ] Marks 3. Attempt any THREE of the
following: 12 a) Explain data and time picker with its method. b) Explain the steps to install and configure
Android studio and SDK. c) Explain the activity life cycle. d) Explain the steps to deploy app on Google Play
Store. 4. Attempt any THREE of the following: 12 a) Explain the fundamentals of UI design in detail. b)
Write a program to display a rectangular progress bar. c) Explain Android system architecture in detail. d)
Explain the procedure of Geo-coding and reverse Geo-coding. e) Develop an application to send and
receive SMS (Write only .Java and permission tag in manifest file). 5. Attempt any TWO of the following: 12
a) Develop a program to send and receive an Email. b) Develop a program for providing bluetooth
connectivity. c) Develop a program to implement :– i) List view of 5 items ii) Grid view of 4 × 4 items iii)
Image view. 6. Attempt any TWO of the following: 12 a) Develop an application to store customer’s details
like, customer-id, customer-name, mobile number, address, pin-code and retrieve customer information
using customer-id in SQLite databases. b) Write a program to find the direction from user’s current location
to MSBTE, Bandra. (Write only .Java and manifest file). c) Develop a simple calculator using relative layout.

1. Attempt any FIVE of the following:


a) Define OHA and state goal of OHA.
ANS :→ The Open Handset Alliance (OHA) is a business alliance that was created for the purpose of
developing open mobile device standards. The OHA has approximately 80 member companies, including
HTC, Dell, Intel, Motorola, Qualcomm and Google. The OHA’s main product is the Android platform – the
world’s most popular smartphone platform.

b) Define Android Virtual Devices (AVD).


ANS :→ An Android Virtual Device (AVD) is a configuration that defines the characteristics of an Android
phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to simulate in the Android
Emulator. The Device Manager is a tool you can launch from Android Studio that helps you create and
manage AVDs.

c) State how the APK files are built?


ANS :→ To make an APK file, a program for Android is first compiled using a tool such as Android Studio or
Visual Studio and then all of its parts are packaged into one container file. An APK file contains all of a
program's code (such as .dex files), resources, assets, certificates, and manifest file

d) Enlist the elements of UI.


ANS :→ UI elements and interaction
1) Windows, pages, dialogs, and panes.
2) Menu bar.
3) Navigation menu.
4) Toolbar.
5) Buttons and icons.
6) Tab.
7) Text box.
8) List box, combo box, and spin box.

e) State the uses of Intent in Android.


ANS :→ The intent is used to launch an activity, start the services, broadcast receivers, display a web page,
dial a phone call, send messages from one activity to another activity, and so on.

f) Name any four methods to get location data in android.


ANS :→ 1) float distanceTo(Location destination) It returns an approx. ...
2) float getAccuracy() ...
3) double getAltitude() ...
4) double getLatitude() ...
5) double getLongitude() ...
6) float getSpeed() ...
7) void setAccuracy(float accuracy) ...
8) void setAltitude(double altitude)

g) Explain significance of content provider.


ANS :→ Content providers can help an application manage access to data stored by itself or stored by
other apps and provide a way to share data with other apps. They encapsulate the data and provide
mechanisms for defining data security.

------------------------------------------------------------------------------------------------------------------------------------------

2. Attempt any THREE of the following:


a) Describe the different features of Android.

ANS :→ 1. Near Field Communication (NFC): Most Android devices support NFC, which allows electronic
devices to interact across short distances easily. The main goal here is to create a payment option that is
simpler than carrying cash or credit cards, and while the market hasn't exploded as many experts had
predicted, there may be an alternative in the works, in the form of Bluetooth Low Energy (BLE).

2. Infrared Transmission: The Android operating system supports a built-in infrared transmitter that allows
you to use your phone or tablet as a remote control.

3. Automation: The Tasker app allows control of app permissions and also automates them.

4. Wireless App Downloads: You can download apps on your PC by using the Android Market or third-
party options like AppBrain. Then it automatically syncs them to your Droid, and no plugging is required.
5. Storage and Battery Swap: Android phones also have unique hardware capabilities. Google's OS makes
it possible to upgrade, replace, and remove your battery that no longer holds a charge. In addition, Android
phones come with SD card slots for expandable storage.

6. Custom Home Screens: While it's possible to hack certain phones to customize the home screen,
Android comes with this capability from the get-go. Download a third-party launcher like Apex, Nova, and
you can add gestures, new shortcuts, or even performance enhancements for older-model devices.

b) Explain features of Android SDK.

ANS :→ Generally Android tools are not platform dependent and are required on every Android Platform,
no matter which you use. While we install AndroidStudio, there are some sets of tools that automatically
get installed. Those set of tools are explained below for you

1. Android Tool: This tool helps in managing the Android Virtual Device projects as well as the installed
components of the software development kit.

2. Emulator Tool: It helps us in testing the applications without the need of using the application on an
actual device.

3. ddms: DDMS is very useful for debugging the Android Application.

4. Android Debug Bridge(adb): It is a very versatile command-line tool and is helpful for the
communication between the developer and the Emulator or the Android device that is connected.

5. Proguard: Proguard is the tool responsible for shrinking, and optimizing our code. It does this, by
removing the unused code or the codes that are unreachable.

c) Explain the Android security model.


ANS :→

The security model is based on the consent of the following parties:

1. Operating System

2. Application

3. End-User
Since Android is primarily focused on the end user, the system has to be secure by default.

The user expects the other two parties to have taken the necessary measures to ensure his safety.
However, when the nature of the action requires his consent, the end-user is the decisive factor when it
comes to the security of the overall system.

For the rest of the article, we will explore the security measures enforced by the three parties in order to
prevent malicious actions from being successfully executed.

1. Operating System Security

The kernel is the core operating system software that handles the CPU resources, the system memory, the
system devices, including the file systems and networking, and is responsible for managing all the processes.
It serves as a link between the software and the hardware.

However, with great power comes great responsibility. The kernel security determines the overall security
of the whole system.

Android’s kernel is based on the Linux kernel’s long-term support (LTS) branches. The decades of
continuous improvement have established Linux as a stable and reliable kernel amongst many businesses
and security professionals.

The security of the Android operating system is based around the following key security features of the
Linux kernel:

 Process Isolation

 User-Based Permission Model

 Inter-Process Communication (IPC)

d) Elaborate the need of permissions in Android. Explain the permissions to set system
functionalities like SEND-SMS, bluetooth.

ANS :→ What are Android app permissions?


As the name suggests, permissions govern what an app is allowed to do and access. This ranges from
reading the data stored on your phone, such as SMS messages and media files, through to using hardware
including your handset’s camera or microphone. Granting permission allows the app to use the feature.
Denying access prevents it from doing so. Simple enough.

3. Attempt any THREE of the following:


a) Explain data and time picker with its method.

ANS :→
Date picker:

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


<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"
tools:context="example.javatpoint.com.datepicker.MainActivity">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="102dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:text="" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Change Date" />

<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp" />

</RelativeLayout>
Time picker:
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="example.javatpoint.com.timepicker.MainActivity">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="102dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:text="" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Change Time" />

<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp" />
</RelativeLayout>

b) Explain the steps to install and configure Android studio and SDK.
ANS :→Installation Guide

Step 1: Head over to this link to get the Android Studio executable or zip file.
Step 2: Click on the Download Android Studio Button.
Click on the “I have read and agree with the above terms and conditions” checkbox followed by the
download button.
Click on the Save file button in the appeared prompt box and the file will start downloading.
Step 3: After the downloading has finished, open the file from downloads and run it. It will prompt the
following dialog box.
Click on next. In the next prompt, it’ll ask for a path for installation. Choose a path and hit next.
Step 4: It will start the installation, and once it is completed, it will be like the image shown below.
Click on next.
Step 5: Once “Finish” is clicked, it will ask whether the previous settings need to be imported [if the
android studio had been installed earlier], or not. It is better to choose the ‘Don’t import Settings
option’.
Click the OK button.
Step 6: This will start the Android Studio.
Meanwhile, it will be finding the available SDK components.
Step 7: After it has found the SDK components, it will redirect to the Welcome dialog box. Click
on Next. Choose Standard and click on Next. Now choose the theme, whether the Light theme or
the Dark one. The light one is called the IntelliJ theme whereas the dark theme is called Dracula. Choose
as required. Click on the Next button.
Step 8: Now it is time to download the SDK components.
Click on Finish. Components begin to download let it complete.
The Android Studio has been successfully configured. Now it’s time to launch and build apps. Click on the
Finish button to launch it.
Step 9: Click on Start a new Android Studio project to build a new app.
To run your first android app in Android Studio you may refer to Running your first Android app.

c) Explain the activity life cycle.


ANS :→
Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class. The android Activity is
the subclass of ContextThemeWrapper class.

An activity is the single screen in android. It is like window or frame of Java.

By the help of activity, you can place all your UI components or widgets in a single screen.

The 7 lifecycle method of Activity describes how activity will behave at different states.

Android Activity Lifecycle method.

Method Description

onCreate called when activity is first created.

onStart called when activity is becoming visible to the user.

onResume called when activity will start interacting with the user.

onPause called when activity is not visible to the user.

onStop called when activity is no longer visible to the user.

onRestart called after your activity is stopped, prior to start.

onDestroy called before the activity is destroyed.

d) Explain the steps to deploy app on Google Play Store.


ANS :→

Step 1: Make a Developer Account


A developer account is must be needed to upload an app on the Google Play Store, and the process is
very simple. Just go through Google Play Store and do as instructed.
The account can be created in four simple steps:
Sign-In with Your Google Account
Accept Terms
Pay Registration Fee of $25.
Complete Your Account Details

Step 2: After you completed step 1 you will be redirected to this page where you have to click on
the CREATE APPLICATION button.
Once you click on it a pop up will be shown like this where you have to choose your Default
language and Title of your app. Then click on the CREATE button.
Step 3: Store listing
After you completed step 2 you will be redirected to this page where you have to provide the Short
description and Full description of your App.
Then you scroll down the page and now you have to add the Hi-res icon of your app. Then you have to
provide the Screenshots of your app.Ant next thing you have to provide is the Feature Graphic of your
app. Note that this graphic is then used everywhere your app is featured on Google Play.
Then come to Categorization part where you have to provide your Application type and Category of
your app.
Then come to Contact details part where you have to provide your Website(if any), email, and Phone of
yours.
And finally when you click on SAVE DRAFT button you can see that Store listing tab is now become
turned to green and you are done for Store listing.

Step 4: App release


After completing step 3 go to App releases then scroll down to Production track and click
on MANAGE button.
After redirecting to the next page click on the CREATE RELEASE button.
After that on the next page, you have to upload your APK file in Android App Bundles and APKs to
add section.
After that simply click on the SAVE button.
Step 5: Content rating Now after completing step 4 go to Content rating and click
on CONTINUE button.
After that fill your email address as well as confirm the email address.
And then Select your app category.
After selecting your app category make sure that you read all of these and answer them correctly.
And after answering them correctly don’t forget to click on SAVE QUESTIONNAIRE button.
Once you saved all those things then click on CALCULATE RATING button.
When you redirected to another page scroll down and click on APPLY RATING button. And you are done
for Content rating section. Don’t forget to notice that Content rating section is now become turned to
green.

Step 6: Pricing & distribution


Then go to the Pricing & distribution section. Then select the country in which you want to available
your app.
Then go down and down and check out the Content guidelines and US export laws section by marking
them tick mark. And click on the SAVE DRAFT button. Don’t forget to notice that Pricing &
distribution section is now become turned to green tick.
Step 7: App content
Then come to the App content section. And in the Privacy policy section click on the Start button.
And then provide a valid Privacy policy URL. Note that google will check this.
Then go back and continue further steps by clicking start button in Ads section.
Then select does your app contain ads or not? And click on SAVE button.
Then again go back and continue further steps by clicking start button in Target audience and
content section.
In the next page select the Target age group and scroll down and click on the Next button.
Then check the Appeal to children section. And click on the Next button.
On the next page click on the Save button and you are done for App content section.

Step 8: App releases


Again go back to the App releases section. And in the Production track click on the EDIT
RELEASE button.
Then on the next page go down and down and click on the REVIEW button.
And finally, on the next page click on the START ROLLOUT TO PRODUCTION button to send your app to
review. And you are finally done.
After usually 4 to 5 days they will review your app and let you know to either approve or reject your
app.

4. Attempt any THREE of the following:


a) Explain the fundamentals of UI design in detail.
ANS :→ The user interface (UI) is the point of human-computer interaction and communication in a device.
This can include display screens, keyboards, a mouse and the appearance of a desktop. It is also the way
through which a user interacts with an application or a website.

The growing dependence of many businesses on web applications and mobile applications has led many
companies to place increased priority on UI in an effort to improve the user's overall experience.

Types of user interfaces


The various types of user interfaces include:
 graphical user interface (GUI)
 command line interface (CLI)
 menu-driven user interface
 touch user interface
 voice user interface (VUI)
 form-based user interface
 natural language user interface

Examples of user interfaces


Some examples of user interfaces include:

 computer mouse
 remote control
 virtual reality
 ATMs
 speedometer
 the old iPod click wheel

Websites such as Airbnb, Dropbox and Virgin America display strong user interface design. Sites like these
have created pleasant, easily operable, user-centered designs (UCD) that focus on the user and their
needs.

UI and UX
The UI is often talked about in conjunction with user experience (UX), which may include the aesthetic
appearance of the device, response time and the content that is presented to the user within the context
of the user interface. Both terms fall under the concept of human-computer interaction (HCI), which is the
field of study focusing on the creation of computer technology and the interaction between humans and all
forms of IT design. Specifically, HCI studies areas such as UCD, UI design and UX design.An increasing focus
on creating an optimized user experience has led some to carve out careers as UI and UX experts. Certain
languages, such as HTML and CSS, have been geared toward making it easier to create a strong user
interface and experience

b) Write a program to display a rectangular progress bar.

ANS :→
<RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="116dp"
android:text="download file" />

</RelativeLayout>

c) Explain Android system architecture in detail.

ANS : → Android architecture contains different number of components to support any


android device needs. Android software contains an open-source Linux Kernel having
collection of number of C/C++ libraries which are exposed through an application
framework services.
Among all the components Linux Kernel provides main functionality of operating system
functions to smartphones and Dalvik Virtual Machine (DVM) provide platform for running
an android application.
The main components of android architecture are following:-

 Application Framework
 Application
 Android Runtime
 Platform Libraries
 Linux Kernel
 Pictorial representation of android architecture with several main components and
their sub components –

5. Attempt any TWO of the following:


a) Develop a program to send and receive an Email.
ANS :→

<!-- activity_main.xml -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

<!-- Email recipient -->

<EditText

android:id="@+id/editTextRecipient"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Recipient" />

<!-- Email subject -->

<EditText

android:id="@+id/editTextSubject"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Subject" />

<!-- Email body -->

<EditText

android:id="@+id/editTextBody"

android:layout_width="match_parent"
android:layout_height="wrap_content"

android:hint="Body"

android:inputType="textMultiLine"

android:lines="5" />

<!-- Button to send email -->

<Button

android:id="@+id/buttonSend"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Send Email" />

<!-- TextView to display received emails -->

<TextView

android:id="@+id/textViewReceivedEmails"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Received Emails"

android:textSize="18sp"

android:textStyle="bold" />

<!-- ListView to display received emails -->

<ListView

android:id="@+id/listViewReceivedEmails"

android:layout_width="match_parent"

android:layout_height="wrap_content" />

</LinearLayout>
b) Develop a program for providing bluetooth connectivity.
ANS :→

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.bluetoothexample">

<uses-permission android:name="android.permission.BLUETOOTH" />

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

<application

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_round"

android:supportsRtl="true"

android:theme="@style/AppTheme">

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<service

android:name=".BluetoothService"

android:enabled="true"

android:exported="false" />

</application>
</manifest>

c) Develop a program to implement :–

i) List view of 5 items

ii) Grid view of 4 × 4 items

iii) Image view.


ANS :→

i) List view of 5 items


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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

<ListView

android:id="@+id/listView"

android:layout_width="match_parent"

android:layout_height="match_parent" />

</LinearLayout>

ii) Grid view of 4 × 4 items


<GridLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/gridLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:columnCount="4"

android:rowCount="4">

<!-- Item 1 -->


<Button

android:id="@+id/button1"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 1" />

<!-- Item 2 -->

<Button

android:id="@+id/button2"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 2" />

<!-- Item 3 -->

<Button

android:id="@+id/button3"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 3" />

<!-- Item 4 -->

<Button

android:id="@+id/button4"

android:layout_width="0dp"

android:layout_height="0dp"
android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 4" />

<!-- Item 5 -->

<Button

android:id="@+id/button5"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 5" />

<!-- Item 6 -->

<Button

android:id="@+id/button6"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 6" />

<!-- Item 7 -->

<Button

android:id="@+id/button7"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 7" />


<!-- Item 8 -->

<Button

android:id="@+id/button8"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 8" />

<!-- Item 9 -->

<Button

android:id="@+id/button9"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 9" />

<!-- Item 10 -->

<Button

android:id="@+id/button10"

android:layout_width="0dp"

android:layout_height="0dp"

android:layout_columnWeight="1"

android:layout_rowWeight="1"

android:text="Button 10" />

<!-- Item 11 -->

<Button

android:id="@+id/button11"

android:layout_width="0dp"
android:layout_height="0dp"

android:layout_columnWeight

iii) Image view.


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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity">

<ImageView

android:id="@+id/imageView"

android:layout_width="200dp"

android:layout_height="200dp"

android:src="@drawable/my_image"

android:scaleType="centerCrop" />

</RelativeLayout>

6. Attempt any TWO of the following:


a) Develop an application to store customer’s details like, customer-id, customer-name,
mobile number, address, pin-code and retrieve customer information using customer-id
in SQLite databases.
ANS :→

import sqlite3
# Create a connection to the SQLite database

conn = sqlite3.connect('customer.db')

cursor = conn.cursor()

# Create the customers table

cursor.execute('''

CREATE TABLE IF NOT EXISTS customers (

id INTEGER PRIMARY KEY,

name TEXT NOT NULL,

mobile_number TEXT NOT NULL,

address TEXT NOT NULL,

pin_code TEXT NOT NULL

''')

# Commit the changes and close the connection

conn.commit()

conn.close()

import sqlite3

def insert_customer(customer_id, customer_name, mobile_number, address, pin_code):

# Create a connection to the SQLite database

conn = sqlite3.connect('customer.db')

cursor = conn.cursor()

# Insert customer information into the table

cursor.execute('''

INSERT INTO customers (id, name, mobile_number, address, pin_code)

VALUES (?, ?, ?, ?, ?)

''', (customer_id, customer_name, mobile_number, address, pin_code))

# Commit the changes and close the connection

conn.commit()

conn.close()
def retrieve_customer(customer_id):

# Create a connection to the SQLite database

conn = sqlite3.connect('customer.db')

cursor = conn.cursor()

# Retrieve customer information based on customer ID

cursor.execute('''

SELECT * FROM customers WHERE id = ?

''', (customer_id,))

# Fetch the customer record

customer = cursor.fetchone()

# Close the connection

conn.close()

return customer

import sqlite3

def insert_customer(customer_id, customer_name, mobile_number, address, pin_code):

# Create a connection to the SQLite database

conn = sqlite3.connect('customer.db')

cursor = conn.cursor()

# Insert customer information into the table

cursor.execute('''

INSERT INTO customers (id, name, mobile_number, address, pin_code)

VALUES (?, ?, ?, ?, ?)

''', (customer_id, customer_name, mobile_number, address, pin_code))

# Commit the changes and close the connection

conn.commit()

conn.close()
def retrieve_customer(customer_id):

# Create a connection to the SQLite database

conn = sqlite3.connect('customer.db')

cursor = conn.cursor()

# Retrieve customer information based on customer ID

cursor.execute('''

SELECT * FROM customers WHERE id = ?

''', (customer_id,))

# Fetch the customer record

customer = cursor.fetchone()

# Close the connection

conn.close()

return customer

c) Develop a simple calculator using relative layout.


ANS :→

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent">

<EditText

android:id="@+id/etNumber1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="16dp"

android:hint="Number 1"

android:inputType="numberDecimal" />
<EditText

android:id="@+id/etNumber2"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_below="@id/etNumber1"

android:layout_margin="16dp"

android:hint="Number 2"

android:inputType="numberDecimal" />

<Button

android:id="@+id/btnAdd"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@id/etNumber2"

android:layout_marginTop="16dp"

android:layout_marginEnd="8dp"

android:layout_alignParentEnd="true"

android:text="Add" />

<Button

android:id="@+id/btnSubtract"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@id/etNumber2"

android:layout_toStartOf="@id/btnAdd"

android:text="Subtract" />

<Button

android:id="@+id/btnMultiply"

android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:layout_below="@id/btnAdd"

android:layout_marginTop="16dp"

android:layout_marginEnd="8dp"

android:layout_alignParentEnd="true"

android:text="Multiply" />

<Button

android:id="@+id/btnDivide"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_below="@id/btnAdd"

android:layout_toStartOf="@id/btnMultiply"

android:text="Divide" />

</RelativeLayout>

You might also like