Unit-1
Mobile Device and its Feature:
‘Amobile device refers to « handheld electronic device that is designed to be portable and used on the go.
These devices have become an integral part of modem life, offering a wide range of features and
functionalities. E.g. Tablets, e-readers, smartphones, PDAs and portable music player etc. Its features:-
1. Portable: Mobile devices are lightweight and compact, allowing users to carry them easily wherever
they go, providing on-the-go access to essential tools and information,
2. Personal: Mobile devices can be customized with wallpapers, apps, and settings, reflecting individual
preferences and creating a personalized connection. A mobile devices is absolutely personal.
3. Companion: Mobile devices offer constant access to communication, entertainment, and productivity
tools, becoming reliable companions that assist users throughout their daily activities. Mobile Device
‘an be with us anytime.
4, Easy Usage: Mobile devices feature intuitive touchscreens and interfaces, making them user-friendly
and accessible to people of varying levels of technological familiarity.
5. Connected Device: Mobile devices have intemet connectivity, enabling communication with other
devices, access to online services, and the ability to link with a wide range of smart devices.
Categories of Mobile Devices:
1. Mobile Phones: Mobile phones, also known as cell phones or feature phones, are devices primarily
designed for voice communication. They offer basic text messaging, calling, and some limited internet
connectivity. These devices often have physical keypads and smaller screens compared to
smartphones,
2. low£nd Mobile Devices: Low-end mobile devices are basic phones that focus on essential
‘communication functions. They typically have simple interfaces, basic cameras, and limited app
support. These devices are often used as backup phones or by individuals who prefer minimal features.
3. Mid-End Mobile Devices: Mid-end mobile devices are budget-friendly smartphones that offer a
decent balance between performance and affordability. They come with moderate specifications,
including better cameras, improved processors, and a wider range of apps compared to low-end
devices,
4. High-End Mobile Devices: High-end mobile devices, commonly known as flagship smartphones, are
premium devices that offer top-of-the-line specifications and features. They boast powerful
processors, high-quality cameras, advanced display technology, and cutting-edge design. These
devices are often at the forefront of technological innovation.5. Smartphones: Smartphones are advanced mobile devices that offer not only voice calls and text
messaging but also a wide range of computing capabilities. They provide access to the internet,
support various apps for productivity, entertainment, anc communication.
6. Non-Phone Devices: Devices that aren't primarily used for voice calls, such as tablets, smartwatches,
fitness trackers, and portable media players.
Mobile Programming:
Mobile programming is a set of processes and procedures involved in writing software for small, wireless
‘computing devices. Itis the act or process by which mobile apps are developed for mobile devices, such
as personal digital assistants, enterprise digital assistants or mobile phones
‘Two dominant platforms in the modern smartphones market. One is the iOS platform from Apple Inc. The
10S platform is the operating system that powers Apples popular line of Phone smartphones. The second
is android from google. The android OS is not only used by Google device but also by many OEMs to build
their own smartphone and other smart devices.
Language used for mobile programming languages
‘Android : Java, Kotlin, C#, Python ete
IOS: Objectives-C, Swift ete
History of Mobile Devices:
1. 1970s-1980s: Early experiments in wireless communication with car phones and handheld radio
devices,
2. 1983: Motorola introduced the DynaTAC 8000X, the first commercial handheld mobile phone.
3. 1990s: Mobile phones became smaller and more affordable; Nokia's 1011 and text messaging gained
popularity,
4. Late 1990s: Nokia's Communicator introduced basic computing features to mobile phones.
2007: Apple's iPhone redefined smartphones witha touchscreen interface and the App Store.
6. 2008-2009: Google's Android OS emerged as an alternctive to iOS, leading to diverse smartphone
options.
7. 2010s: Smartphone market growth exploded with improved cameras, processing power, and
connectivity.
8 2010s-2020s: Introduction of 4G and 5G technology for faster connectivity.
9 Smartwatches and Wearables: Rise of wearable devices like smartwatches and fitness trackers,
10. Foldable Phones: introduction of foldable smartphones for larger displays.
11. Aland Personal Assistants: Integration of voice assistants lke Siri, Google Assistant, and Alexa.
12. 2020s: Continued evolution with AR, VR, and Al technologies shaping the mobile landscape.Brands, Model and Platform of Mobile Devices:
1. Apple:
+ Brand: Apple
‘+ Models: Notable models include iPhone 13 Pro, Phone 13 Mini, and iPhone SE.
‘* Platform:i0S- Apple's proprietary mobile operating system. Known for its user-friendly interface,
smooth performance, and tight integration with other Apple devices and services.
2. Nokia:
Brand: Nokia
‘© Models: Iconic models from the past include Nokia 3310 (modern version) and Nokia 7.2,
‘+ Platform: Nokia's earlier phones used various proprietary operating systems. In recent years,
many Nokia smartphones have adopted Android as their platform, offering a range of devices
running on different versions of Android with a relatively pure Android experience.
3. BlackBerry:
‘© Brand: BlackBerry
‘+ Models: Notable models include BlackBerry Key? and BlackBerry Motion.
‘Platform: BlackBerry OS was the brand's proprietary operating system. However, mary recent
BlackBerry smartphones have adopted the Android operating system, allowing users to enjoy
BlackBerrys security features and productivity enhancements on Android devices.
4, Samsung:
+ Brand: Samsung
‘+ Models: Prominent models include Samsung Galaxy $21 Ultra, Samsung Galaxy AS2, and
Samsung Galaxy Z Fold 3.
‘Platform: Samsung devices runon the Android operating system with Samsung's customized skin
called One Ul. One Ul adds unique features and a distinct visual style to the Android experience.
5. Motorol
+ Brand: Motorola
‘+ Models: Noteworthy models include Motorola Moto 6 Power, Motorola Edge, and Motorola
Rarr.
‘+ Platform: Motorola devices primarily run on the Android operating system, often offering a near-
stock Android experience with minimal customization, emphasizing simplicity and speed.
6. 1G Mobile:
* Brand: LG Mobile
‘= Models: Notable models include LS Velvet, LG Wing, and LG G8 Thing,
‘+ Platform: LG smartphones use the Android operating system, with G's custom user interface
that provides additional features and a distinct design.
7. Android:
‘+ Platform: Android is an open-source mobile operating system developed by Google. It's used by
many manufacturers and offers a customizable experience with a vast app ecosystem.
8 Windows Mobile (now Windows Phone}:
= Brand: Microsoft
‘* Models: Devices like Windows Phone 8X by HTC, Lumia 950, and Lumia 1520,+ Platform: Windows Phone was @ motile operating system developed by Microsoft. It offered a
unique and visually appealing interface but smo longer actively developed or widely used,
Approaches while Building Mobile App
1._ Native App Development: Native app development involves creating applications specifically for a
particular platform, such as i0S or Android. Developers use platform-specific programming languages
(Swift/Objective-C for i0S, Java/Kotlin for Android) and development tools. This approach offers the
best performance and access to platform-specific features.
2. Cross-Platform Development: Cross-platform development allows creating applications that can run
‘on multiple platforms using a single codebase. Frameworks like React Native, Flutter, and Xamarin
enable developers to write code once and deploy it across different platforms. This approach saves
time and resources by sharing much of the codebase, but it may not provide the same level of
performance and access to native features as native development.
3. Web App Development: Web app development involves creating applications accessible through a
motile browser. Developers use web technologies like HTML, CSS, and JavaScript to build responsive
and accessible apps. Web apps are platform-independent and can be accessed on various devices, but
they may have limitations in terms of performance and access to device-specific features.
4, Progressive Web Apps (PWAs): PWAs are web applications that offer a hybrid experience between
web and native apps. They use modern web technologies and can be accessed through browsers.
PWAs can provide a more appulike experience, including offline capabilities and access to device
features through APIs.
Mobile Application Development Life cycle:
‘There are two interlinked core components of a mobile application
1. The mobile application “Front-End that resides on the mobile device
2. The services “Back-End” that supports the mobile front-end.
The mobile front-end is the visual and interactive part of the application the user experiences. it usually
resides on the device, or there is at least an icon representing the app that is visible on the home screen
or is pinned in the application catalog of the device. The app can be downloaded from the platform app
store, side loaded directly onto the device or can be reached through the device's browser.
Regardless of what front end platform or development methodology is being used, delivering high quality
mobile applications that delight and retain users requires reliable backend services.
Backend development involves building the server-side components of the mobile app that handle data
storage, processing, and communication with external services. It powers the app’s functionality and
supports the frontend interactions.Unit -2
Android
The Android platform is 2 mobile operating system developed by Google. It provides a comprehensive
framework for building and running applications on various devices, including smartphones, tablets, smart
Vs, and more.
History and Version of Android:
Android, developed by Google, is a mobile operating system that debuted in 2008 with Android 1.0.
Subsequent versions were named after treats. Android 2.2 (Froyo) improved performance and added
tethering. Android 4.0 (Ice Cream Sandwich) merged tablet and phone interfaces. Android 5.0 (Lollipop)
introduced "Material Design.” Android 6.0 (Marshmallow) focused on app permissions and battery life.
‘Android 7.0 (Nouget) brought split-screen multitasking. Android 8.0 (Oreo) featured notification channels
and Project Treble. Android 9 (Pie) introduced gesture navigation. Android 10 added a system-wide dark
mode. Android 11 enhanced notifications and multitasking. Android 12 is expected with a visual refresh
and privacy features, continuing Android's evolution,
Environment Setup of Android:
41. Install JDK: Download and install the Java Development Kit (JDK). Set the JAVA_HOME
environment variable.
2. Install Android Studio: Download and install Android Studio, the official IDE for Android
development.
3. Open Android Studio: Launch Android Studio after installation.
4. Install SDK Components: Android Studio will prompt you to install the Android SDK components.
Follow the prompts to download and install them.
5. Configure SDK Path: Android Studio might ask for the SDK location. If it doesn't auto-detect it,
provide the path to the SDK location.
6. SetUp Emulator: Open AVD Manager in Android Studio. Create and set up Android Virtual Devices
[emulators) for testing your apps.
7. Start Coding: Create a new Android project in Android Studio and begin coding your app using
Java or Kotiin.
8. Test Your App: Run your app onan emulator or a physical Android device to test its functionality.Creating an Android Project
1
Open Android Studio:
© Launch Android Studio after
Start a New Android Project:
‘+ Click on "Start a new Android Studio project” on the main welcome screen, or go to File>
New > New Project.
Choose a Project Template:
Select a template that suits your app's type. The mast common choices are "Empty
Activity," "Basic Activity," "Tabbed Activity," etc. Choose one that matches your app's
structure.
Configure Your Project:
Enter the "Name' of your project.
+ Choose a "Package name" for your app (usually in reverse comain format).
+ Selecta "Save location’ for your project.
«Choose the programming language you want to use, either Java or Kotlin.
Select Minimum API Level:
+ Choose the minimum Android version your app should support. This affects which
features and devices your app can be used on.
Add Activity:
© Choose an "Activity Name" and a "Layout Name" for the initial screen of your app. The
activity is where you'll start building your app's functionality.
Customize Actvity:
'* Customize the activity by selecting options related to the layout, navigation, and more.
Finish Setup:
+ Click "Finish” to create your project. Android Studio will generate the necessary files and
resources for your app.
's installed.Widgets and its Attribute:
widgets are interactive Ul components that provide functionality and information directly on the home
screen, lock screen, or within an app's user interface. Widgets can display data, allow user interaction, and
offer quick access to app features without the need to open the app itself.
> Button: The Button widget is used to create interactive buttons that users can click to trigger actions.
1. android:text: Specifies the text displayed on the button.
2. android:textSize: Sets the size of the button's text.
> TextView: The TextView widget is used to display text on the screen, t's often used to show labels,
descriptions, or other types of information.
1. android:text: Specifies the text content of the TextView.
2. android:textSize: Sets the size of the text.
> EditText: The EditText widget is used to allow users to input text. It's commonly used for forms:
1. android:hint: Provides a hint or placeholder text to guide users.
2. android:inputType: Specifies the type of input allowed (text, number, email, etc.)
> ImageView: The ImageView widget is used to display images or drawable on the screen.
1. android:scaleType: Controls how the image is scaled anc displayed within the Image View.
> Checkbox: Checkbox is a specific type of two states button that can be either checked or unchecked.
1. android:accessibilityHeading: Whether or not this view is a heading for accessibility purposes.
2. android:accessiblityPaneTitie: The title this view should present to accessibility asa panetttle.
> RadioButton: A radio button is atwo-state button that can be either checked or unchecked. When the
radio button is unchecked, the user can press or click it to check it. However, contrary toa checkbox,
a radio button cannot be unchecked by the user once checked. Attributes is same as checkbox.
> Spinner: Itis a view that displays one child at a time and lets the user pick among them. The items in
the spinner come from the String array or adapter associated with this view.
1. android:spinnerMode: Display the mode for the spinner options
2. android:entries: Used for loading string array.View Hierarchy With Example:
‘The view hierarchy refers to the structure of Ul elements that make up the user interface of an app. These
UL elements, known as "Views," are organized in a tree-like structure, where each view can have child
views. The root of this hierarchy is the top-level view, often referred to as the "root view.” Understanding
the view hierarchy is essential for designing and manipulating the user interface effectively.
> Root View: The LinearLayout is the root view. It acts as a container for all other views and arranges
them vertically
Child Views: The ImageView, EditText for the username, EditText for the password, and the Button
are child views. They are contained within the Linearlayout and inhert its layout attributes.
This view hierarchy defines the structure of the login screen. The LinearLayout organizes the Ul
‘components, ensuring they appear in the specified order and are aligned vertically. Understanding the
view hierarchy is crucial for designing and positioning UI elements effectively in Android apps.
<2xml versio "uth-8"2>
Manifest File with Example:
‘The [Link]| file is a vital blueprint for Android apps. It provides essential instructions to the
Android system about your app's identity, components (like screens and background tasks}, permissionsit
needs, how it should be launched, and more, Without the manifest, your app won't work correctly or may
not even be installable on devices. It's lke the app's introduction to Android, ensuring proper functioning
and interaction with the device and other apps.
Example
Basic Note App
«action android:name="[Link]. MAIN" />
«action android:name="android [Link]" />
Intent Filter
Intent fiters are a crucial component of an Android app's manifest file. They define the types of intents
(actions) that an app's component (Ike an activity, service, or broadcast receiver) can respond to. Intents
are messages that allow components to request actions from other components, either within the same
app or from different apps.‘Android Virtual Device(AVD)
An Android Virtual Device (AVD) is a software-based emulation of an Android device. It allows developers
to test their apps on different virtual devices with various configurations, Android versions, and screen
sizes. AVDs are helpful for app testing and development without the need for physical devices.
Procedure
41. Open Android Studio: Launch Android Studio on your computer.
2. Access AVD Manager: Go to "Tools" > "AVD Manager’ from the top menu.
3, Create AVD: Click "Create Virtual Device.”
4, Choose Hardware Profile: Select a device definition that matches the type of device you went to
emulate (eg., phone, tablet)
5, Select System Image: Choose the Android version and API evel you want to emulate. if not already
downloaded, click "Download" to get the system image.
6. Configure AVD: Give your AVD 2 name, and adjust settings like RAM size and storage capacity as
needed.
7. Complete Configuration: Click "Finish" to create the AVD.
8, Emulate AVD: Select the newly created AVD from the list and click the green "Play" button tostart
the emulator.
8. Test Your App: The emulator will boot up with the chosen configuration. Test your Android app on
the virtual device.
10. Exit Emulator: When done, close the emulator by clicking the "x" in the emulator window or
selecting "Stop" in the AVD Manager.Unit - 3
Layout:
Alayout refers to the way you arrange Ul elements within an app's user interface. It defines the structure,
positioning, and appearance of various components such as buttons, text views, images, and more.
‘Android provides several types of layout containers that allow you to organize and control the placement
of these Ul elements.
Types of Layo
1. Linearlayout:
«Arranges child views linearly (horizontally or vertically).
‘+ Simple and efficient for straightforward layouts.
+ Good for basic designs, but nesting can impact performance,
2. RelativeLayout:
'* Positions child views relative to each other or parent.
‘Offers precise control over view positioning,
‘+ Useful for complex relationships between views.
3. TableLayout:
‘Organizes child views in rows and columns like a table.
‘+ Suitable for tabular data presentation.
+ Can be less flexible for intricate UI designs.
4, AbsoluteLayout:
'* Positions child views using exact pixel values.
‘+ Deprecated due to lack of responsiveness and adaptability
‘+ Not recommended for modern Android development.
5. ConstraintLayout:
‘© Creates complex layouts with view constraints.
‘© Supports various alignments, centers, and more.
+ Highly versatile, adapts well to different screen sizes,Linear Layout and its Attributes:
Linear Layout is one of the simplest and most commonly used layout containers in Android. It arranges
child views linearly either horizontally or vertically, based on the specified orientation. This layout is
straightforward and efficient for arranging Ul elements ina linear manner.
Attributes:
+ android:orientation: This attribute determines the direction in which child views are arranged. It
canhave two values: "horizontal" or “vertical”.
‘+ android:gravity: Sets the alignment of child views within the LinearLayout.
syout_weight: Distributes any remaining space among multiple views based on their
© androi
weights.
‘+ android:baselineAligned: This attridute controls whether the baseline of child views should be
aligned, Useful when dealing with text views and alignment.
+ android:baselineAlignedChildindex: Specifies the index of a child view whose baseline should be
aligned with the baseline of other child views.
Relative Layot
Relative Layoutis a versatile layout that allows you to create complex UI designs by specifying relationships
between child views interms of their positions and alignments. Unlike Linear Layout, which arranges views
linearly, Relative Layout lets you position views relative to each other or relative to the parent container,
Attributes:
4. android:layout_width and android:layout_height: These attributes define the width and height
of the RelativeLayout. Common values include match_parent and wrap_content.
2. android:layout_alignParentTop android:layout_alignParentBottom,android:layout_alignParent
Left, android:layout_alignParentRight: These attributes align the view's top, bottom, left, or right
edge with the corresponding edge of the parent layout.
3. android:layout_alignTop,android:layout_alignBottom android:layout_alignleft,android:layout,
_alignRight: These attributes align the view's top, bottom, left, or right edge with the
corresponding edge of another view within the same RelativeLayout,
4, android:layout_centerHorizontal,android:layout_centerVertical,android:layout_centerinParen:
These attributes center the viewhorizontally, vertically, or both, respectively, within parent layout.
5. android:layout_alignWithParentlfMissing: When set to true, the view will align with the parent's
edge ifthe referenced view in relative positioningis missing.
Constraint Layout:
Constraint Layout is a powerful and flexible layout container in Android that enables you to create complex
UI designs with efficent performance. It allows you to define relationships (constraints) between UI
elements, making it easier to build responsive and adaptive layouts that work well across different screen
sizes and orientations.
Its Attributes:
1. app:layout_constraintTop_toTopOt,app:layout_constraintBottom_toBottomof,
appilayout_constraintStart_toStartOf, app:layout_constraintEnd_toEndOf; These attributes
define vertical and horizontal constraints, anchoring a view's top/bottom/start/end edge to
another view's corresponding edge.2. app:layout_constraintTop_toBottomOf,app:layout_constraintBottom_toTopOf,
app:layout_constraintStart_toEndOf, app:layout_constraintEnd_toStartOf: These attributes,
create vertical and horizontal constraints, positioning a view relative to another view's edge
Linear Layout vs Relative Layout
Aspect RelativeLayout LinearLayout
Position views relative to each other
JArrangement or parent, ‘Arranges views linearly (horizontally or vertical
Suitable for_complex_layouts_with
Complexity _precise alignment, Best for simple, straightforward arrangements.
Can_be slower for deeply nested Efficient for_most_scenarios, especially simple
Performance _ hierarchies. layouts,
Can_lead to_complex_and_nested Nests easily for simple layouts, but excessive nesting
Nesting hierarchies might impact performance.
Alignment —_Fine-grained alignment control using Limited alignment options: start, end, center, and
Control attributes. space-between,
Canbe less flexible when dealing with
Flexibility responsiveness. Limited responsiveness in complex designs,
Guidelines No built-in guidelines, No built-in guidelines,
Chains No builtin chains, No built-in chains,
Good for Uls with fixed alignments
Best Practices and positions. Best for simpler Uls and quickly prototyping,
[Aspect
Positioning
Complexity
Performance
Nesting
Alignment
Control
Flexibility
Guidelines
Chains
Relative Layout and Constraint Layout:
RelativeLayout ConstraintLayout
Position views relative to each other or
parent Position views with flexible constraints.
Suitable for complex layouts with precise Excellent for complex layouts with
alignment responsiveness.
Generally performs well even with
Can be slower for deeply nested hierarchies. complexity.
Reduces nesting due to flexible constraint
Can lead to complex and nested hierarchies. system.
Fine-grained alignment control _using Extensive alignment and control through
attributes. constraints.
Can be less flexible when dealing with Offers excellent responsiveness through
responsiveness. constraints.
Offers builtin guidelines for flexible
No buiit-in guidelines. alignment,
No built-in chains, Provides built-in chains for even distribution.[Aspect RelativeLayout ConstraintLayout
Good for Uls with fixed alignments and
Positions. Best for responsive and complex Ul.
| Best Practices
Text View:
EditText:
Button:
ImageView
RadioButton:
RadioButton
android:id="@+id/radioButtonl"
android:layout_width="wrep_content"
android:layout_height="wrap_content"
android:text="Option 1° />
@crawable/ic_launcher" />
Widget Example:
RadioButton
android:
‘@id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
androidtext="Option 2" />Spinner:
Spinner
android:id="@+id/spinner"
android:layout_widt
android:layout_height="wrap_content"
android:entries
@array/items_array"
android:prompt="Select an item" />
Event Handling:
Events are a useful way to collect data about a user's interaction with interactive components of
Applications. Like button presses or screen touch etc. The Android framework maintains an event queue
as first-n, first-out (FIFO) basis. You can capture these events in your program and take appropriate action
as per requirements
There are following three concepts related to Android Event Management ~
Event Handler Event Listener & Description
‘OnClicklistener()
conClick() Thisis called when the user either clicks or touches or focuses upon any widget like button,
Event Listeners - An event listener is an interface in the View class that contains a single callback
method. These methods will be called by the Android framework when the View to which the
listener has been registered is triggered by user interaction with the item in the UI.
Event Listeners Registration - Event Registration is the process by which an Event Handler gets
registered with an Event Listener so that the handler is called when the Event Listener fires the
event.
Event Handlers - When an event happens and we have registered an event listener for the event,
the event listener calls the Event Handlers, which is the method that actually handles the event
text, image etc. You will use onClick() event handler to handle such event.
‘OnLongClicktistener()
ontongClick() text, mage etc. for one ormore seconds. You will use onLongClick() event handler to handle
such event.
‘OnFocusChangeListener()
onFocusChange() This is called when the widget looses its focus ie. user goes away from the view item. You
will use onFocusChange() event handler to handle such event.
‘OnFocusChangeListener()
onkey() Thisis called when the user is focused on the item and presses or releases a hardware key
‘on the device. You will use onkey() event handler to handle such event.
‘OnTouchtistener()
ontouch() Thisis called when the user presses the key, releases the key, or any movement gesture on
the screen. You will use onTouch|) event handler to handle such event.
Thisis called when the user either clicks or touches or focuses upon any widget like button,‘OnMenultemClickListener()
onMenultemClick() This is called when the user selects a menu item. You will use onMenultemClick() event
handler to handle such event.
‘onCreateContextMenultemtistener{)
\CreateContextM
onCreateContextMenu() oy. called when the context menu is being built(as the result ofa sustained "long dick)
‘Working with color in Android:
Colors are usually stored in a resource file named [Link] in the /res/values/ folder.
They are defined by
elements:
#3F51B5
#303F9F
#FF40B1
#66000000
String and String Array
String isa XML resource that provides a single string while string array ia a XML resource that provides an
array of strings.
Using String Array:
> XML file saved at res/values/[Link]:
<1 res/values/[Link] >
pp_name">My App
«string name="welcome_message">Welcome to my appl
‘
This layout XML applies a string to a view as follows:
<1- layout/activity_mainxml —>
android:layout_height="wrap_content"
- Apple
android:layout_width="match_parent"
- Banana
android:layout_height="wrap_content”
- Orangec/item> android:entries="@array/fruits" />
IOS and iOS Programming
10S is a mobile operating system developed by Apple Inc. It powers a range of Apple devices, including the
iPhone, iPad, iPod Touch, and Apple TV. iOSis known for its user-friendly interface, security features, and
seamless integration with other Apple devices and services.
10S programming refers to the process of creating applications, commonly referred to as "apps," that run
‘on 10S devices. These apps can serve various purposes, such as productivity, entertainment,
‘communication, education, and more. iOS programming primarily invowves using the Swift programming
language and Apple's development tools to design, develop, and deploy applications
iOS Versions
‘+ iPhone OS 1 ~Released June 29, 2007 (Latest 1.1.5 July 15, 2008)
iPhone OS 2 -Released July 11, 2008 (Latest 2.2.1 January 27, 2008)
iPhone OS 3 ~Released June 17, 2009 (Latest 3.2.2 August 11, 2010)
iOS 4 Released June 22, 2010 (Latest 4.3.5 July 25, 2011)
iOS 5 Released October 12, 2011 (Latest 5.1.1 May 7, 2012)
iOS 6 -Released September 19, 2012 (Latest 6.1.6 February 21, 2014)
iOS 7 ~Released September 18, 2013 (Latest 7.1.2 June 30, 2014)
iOS 8 ~Released September 17, 2014 (Latest 8.4.1 August 13, 2015]
iOS 9 ~Released September 16, 2015 (Latest 9.3.6 July 22, 2019)
iOS 10 - Released September 13, 2016 (Latest 10.3.4 July 22, 2019)
iOS 11 - Released September 19, 2017 (Latest 11.4.1 July 9, 2018)
iOS 12 - Released September 17, 2018 (Latest 12.5.7 January 23, 2023)
‘+ 10513 ~ Released September 19, 2019 (Latest 13.7 September 1, 2020)
‘+ i0514~ Released September 17, 2020 (Latest 14.8.1 October 26, 2021)
‘+ 10515 ~ Released September 24, 2021 (Latest 15.7.5 April 10, 2023)
‘+ 10516 ~ Released September 12, 2022 (Latest iOS 16.5 May 18, 2023)
iOS 17 - in Beta, full release expected in September 2023.
Environment Setup
Setting up the iOS development environment involves a seriesof steps on a Mac computer running macOS.
Start by installing Xcode from the Mac App Store, which provides essential tools for coding, designing
interfaces, debugging, and deploying apps. Obtain an Apple Developer account for testing on physical
devices and distribution. Choose between Swift or Objective-C as your programming language. Utilize
Xcode's simulators for testing and interface design, or connect physical devices after configuring them fordevelopment. Create a new project using provided templates, design your app's interface visually using
Interface Builder and Storyboards, and implement functionality with code. Debug your app using Xcode's
tools and test it on simulators or devices. Configure certificates and provisioning profiles to prepare for
distribution on the App Store. Regularly refer to Apple's official documentation for accurate and up-to-
date guidance throughout the development process.
Creating an Xcode Project
41. Open Xcode: Launch Xcode on your Mac.
2. Create a New Project: In the welcome window, click "Createa new Xcode proje
New > Project
3. Choose Template: Select a template for your project (e.g, "App" for a new iQS app).
4, Configure Project: Fillin project details ike name, organization, and other settings.
5. Choose Location: Select where to save your project files on your computer.
. Git Integration: Optionally, set up Git version control for your project.
7. Choose Options: Configure additional options like Swift UI or UI Kit for your user interface,
8. Create: Click "Create" to generate your project files and structure.
8. Start Developing: Your project is now set up, and you can begin coding, designing interfaces, and
building your app using Xcode's tools.
"or goto File>
Running On the Simulator
Torun your OS application using the simulator in Xcode, first open Xcode on your Mac and load the project
containing your app. Choose a simulator device from the dropdown menu in the top left corner, which
determines the simulated device for testing. Click the "Build and Run” button in Xcode's toolbar or press
Command + R to initiate the process. Xcode compiles your apo's code and launches the chosen simulator,
where you can interact with your app as if it were on a real device. You can test functionalities, navigate
the user interface, and utlize debugging tools if issues arise. To stop the app, click the "Stop" button or
press Command + Period, and to quit the simulator, close its window. While the simulator is a valuable
tool for initial testing, remember to also test on physical devices to ensure an accurate assessmert of your
app's performance and user experience.
‘Swift Language and its Features
Swift is @ powerful and modern programming language developed by Apple for building a wide range of
applications across various platforms, includingiQS, macOS, watchOS, and tvOS. it wasintroduced in 2014
as a replacement for Objective-C, offering a more expressive, safe, and efficient way to develop software.
4. Safety: Swift is designed with a focus on safety and robustness. I prevents common programming
errors and offers features like optional and strong typing to handle null values and type-related
issues.
2. Performance: Swift is designed to be fast and efficient. Its syntax is concise, and it's compiled into
optimized machine code, resulting in better performance compared to some other languages.3. Modern Syntax: Swift features a clean and expressive syntax that's easy to read and write. Its
syntax draws inspiration from multiple languages, making it intuitive for developers to grasp.
4. Open Source: Swift is open source, allowing the developer community to contribute to its
improvement, and enabling its use on a broader range of platforms beyond Apple's ecosystem.
Built-in Data Types of Swift:
> Integers:
© Int: Platform-dependent size integer type usually 32 or 64 bits).
© Int8, Int6, Int32, Int64: Fixed-size integer types with different bit widths.
> Unsigned Integers:
© Uint: Platform-dependent size unsigned integer type.
© Ulnt8, UInt16, Uint32, Uint64: Fixed-size unsigned integer types.
> Floating-Point Numbers:
2 Float: Single-precision floating-point type.
© Double: Double-precision floating-point type.
Bool: Represents true or false values.
Characters: Represents a single Unicode character.
Strings: Represents a sequence of characters.
Tuples: Tuples allow you to group multiple values of different types into a single compound value.
v
vvve
Optional: Represents a value that can either have a value (Some] or no value (nil).
View and View Hierarchy
a "View" is a fundamental building block of a user interface. A view is a rectangular area that can display
content and respond to user interactions. It can represent a button, label, image, text field, or any other
User interface element. Views can be arranged hierarchically to create complex user interfaces. This
hierarchy is known as the "view hierarcty,”
Here's a brief explanation of views and the view hierarchy:
View: A view isa visual element that can display content and interact with the user. It's a rectangular area
with specific properties and behaviors. Views can include Ul elements like buttons, labels, images, and text
fields. IniOS development, views areinstances of the UIView class (or its subclasses}, and they encapsulate
both the visual representation and behavior of user interface elements.
View Hierarchy: The view hierarchy is the organized structure formed by nesting views within each other.
Each view has a parent view, and it can contain child views. The top-level view is the root view, usually
associated with the view controller's main view. Child views are positioned relative to their parent views
and can be manipulated, animated, and styled independently
Subview and Superview: A view that’s contained within another view is called a "subview,” and the view
containing the subview is referred to as the "superview" This forms a parent-child relationship.
Manipulating a superview might affect its subviews, and changing 2 subview's properties can impact its
appearance within the superview.View Hierarchy Importance: Understanding the view hierarchy is crucial for designing responsive and
interactive user interfaces, Property structuring the hierarchy ensures efficient rendering, responsiveness
to user interactions, and effective management of screen layout. It also facilitates the use of layout
constraints, which help ensure your app's appearance adapts to different screen sizes and orientations.
In summary, views are the visual components that form user interfaces in iOS apps, and the view hierarchy
is the way they're organized and nested within each other. This hierarchy enables you to create complex
and dynamic user interfaces while maintaining efficient rendering and responsiveness.
UI control with description
2
Button (UIButton: Buttons allow users to trigger actions when they tap on them. They can have
different styles, titles, images, and even be customized with animations.
Label (UiLabel): Labels display static or dynamic text content, Theyre often used to provide
information, instructions, or display data.
Text Field (UMTextField): Text fields allow users to input text or numbers. They can be used for
things ike entering a username, password, or search query.
Text View (UMTextView); Similar to text fields, text views allow users to enter and edit multiline
text. They're suitable for longer pieces of text, like comments or descriptions.
Switch (UlSwitch): Switches are used for binary choices, like turning a setting on or off.
Slider (UlSlider): Sliders enable users to select a value from a range by siding a thumb along a
track. They're often used for settings like volume or brightness.
Segmented Control (UISegmentedControl): Segmented controls display @ set of mutualy
exclusive options. Users can choose one option from the lst.
Date Picker (UIDatePicker): Date pickers allow users to select dates and times using a graphical
interface.
Progress View (UlProgressView): Progress views show the progress ofa task, suchas downloading
a file or loading content.Story Board and View Controller
Storyboard: A storyboard is a visual representation of the user interface flow of your app. It's a single file
that contains multiple view controllers and the transitions between them. Storyboards allow you to design
and structure your app's user interface visually, making it easier to see how different screens are
connected.
Example: Social Media App Imagine you're building a social media apo with two main screens: a feed
screen and a profile screen.
4. Creating a Storyboard:
‘© Open Xcode and create a new project.
‘+ Open the [Link] fle, which serves as your app's storyboard canvas.
2. Adding View Controllers:
‘© Drag and drop a Navigation Controller onto the storyboard canvas. This will become the
starting point of your app's navigation flow.
‘+ Add a Table View Controller as the initial view controller. This will represent your feed
screen.
+ Adda View Controller for the user's profile screen.
3. Connecting View Controllers
‘+ Control-drag from the Table View Cell in the feed screen to the profile screen, creatinga
segue. Choose "Show' as the segue type.
‘© This connection signifies that tapping on a cell in the feed screen will lead to the user's
profile screen
View Controllers: A view controller isa Swift or Objective-C class that manages a specific screen or view in
your app. It controls the appearance, behavior, and interactions of its associated view(s). Each view
controller has a corresponding scene in the storyboard.
Example Continued:
1. Feed View Controller (FeedViewController|:
‘© This view controller manages the feed screen, displaying posts and updates.
‘*Itconnects to a table view to display alist of posts.
‘+ It fetches data from a data source (e.g, APl) and populates the table view.
2. Profile View Controller (ProfleViewControlle
‘© This view controller manages the user's profile screen.
‘© It displays user information, profile picture, and recent activity.
‘+ It might have buttons to edit the profil, view followers, or send a message.
3. Interactions:
‘© Whena user taps ona cell in the feed screen, the feed view controller triggers a segue to
the profile view controller, showing the profile details of the selected user.
In this example, the storyboard visually depicts how the feed screen and profile screen are connected
through view controllers. The storyboard defines the navigation flow, and each view controller manages
the content and interactions of its respective screen.
Storyboard: Main storyboard
«Navigation Controller (Starting Point)
‘+ Feed View Controller (Initial View Controller)
‘© Table View (Displays posts}
© Segue to Profile View ControllerUnit - 4
‘Android Activity Life cycle:
he activity lifecycle refers to the series of states and trarsitions that an activity goes through during its
existence, Understanding the activity lifecycle is crucial for managing the behavior of your app, handling
User interactions, and optimizing resource usage. Here's an overview of the various stages in the Android
activity lifecycle:
1. onCreate: This method is called when the activity is first created. t's where you typically initialize
your Ul and set up any resources,
onStart: Called when the activity becomes visible to the user, but it's not yet in the foreground.
‘onResume: Celled when the activity is fully visible and in the foreground. This is a good place to
start animations and resume any ongoing processes.
4, onPause: Called when the activity is partially obscured or no longer in focus but still visible to the
user. Use this method to pause ongoing operations or save data
5. onStop: Called when the activity is no longer visible to the user. This is where you can release
resources that are no longer needed.
6. onDestroy: Called before the activity is destroyed. This is your last chance to clean up resources
or save important data.
Example:
import [Link];
import [Link]. Bundle;
public class MainActivity extends AppCompatActivty {
@Override
protected void onCreate(Bundle savedinstanceState) {
[Link](savedinstancestate);
setContentView(Rlayoutactivity_main);
}
@Override
protected void onStart(){
[Link](|;
}
@Override
protected void onResume() {
[Link](|;
}
@Override
protected void onPause() {
[Link]);
}
@Override
protected void onStop(){
[Link]();
}
@Overrideprotected void onDestroy() {
[Link]();
»
Creating multiple activity:
FirstActivity,java secondActivity,java
import [Link]; impor android appcomaat spp AopCompactity;
import [Link]. Bundle; import [Link] Bundle;
import [Link];
import [Link] Button;
public class FirstActivity extends AppCompatActivity { change in FirstActivity to second
@Override same
protected void onCreate(Bundle savedinstanceState) { same
[Link](savedinstanceState]; same
setContentView(Rlayoutactivity_first); activity_first to second;
Button clickMeButton = findViewByld([Link]); y
clickMeButton setOnClickListener(new [Link]() {
@Override
public void onCick(View v] {
startActivity|SecondActivityclass);
}
yi
} private void startActvity(Class> cls) {
startActivity(new Intent(this, cls);
finish();
}
}
activity_first.xml
For activity_second.xml same
Declaring Activities in Manifest:
application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label=" @string/app_name"
android:theme=" @style/AppTheme">
activity android:name="FirstActivity">
«action android:name="[Link]. MAIN" />
«category android:name="[Link] LAUNCHER" />
Create 3 PopupMenu instance with an anchor view.
> Inflate the menu resource using [Link]()nflate([Link].popup_menu,
[Link]()).
> Set an OnMenultemClickListener to handle menu item clicks.
Usage: Used for displaying a list of related actions or options in a compact form.Dialogs:
‘Adialogiss asmall window thet appears on top of the current activity to prompt the user for input, display
information, or offer choices. Dialogsare commonly used to obtain user input or provide feedback without
requiring the user to navigate to a diferent screen or activity. There are several types of dialogs in Androi
1. AlertDialog: An AlertDialog is a commonly used dialog that displays a message, along with buttons for
various actions, such as confirming or canceling an action.
2. ProgressDialog: A ProgressDialog shows a progress indicator, typically used to inform the user about a
background task's progress. This is useful when a time-consuming operation is being performed.
3, DatePickerDialog and TimePickerDialog: These dialogs allow users to select a date or time respectively
froma graphical interface
4. Custom Dialogs: Custom dialogs can be created to display content tailored to your app's needs. You can
design and define the layout for custom dialogs and include any Ul components you want.
Alert Dialogs Examp|
import [Link];
import [Link];
import [Link];
import [Link];
Public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedinstanceState) {
[Link](savedinstancestate];
setContentView(Rlayoutactivity_main);
// Create and show an AlertDialog
‘AlertDialog Builder builder = new [Link](this);
buildersettitle("Alert!")
.setMessage("Do you want to proceed?")
_setPositiveButton("Yes", new [Link]() {
@override
public void onClick(Dialoginterface dialog, int which) {
1/ User clicked Yes
}
y
_setNegativeButton("No", new [Link]() {
@override
public void onClick(Dialoginterface dialog, int which) {
// User clicked No
}
v)
-setNeutralButton( "Cancel", null
show();Unit-6
List View and its Attributes :
AlistView is a fundamental Ul widget in Android that displaysa vertically scrollable listof items. Each item
in the list is represented by a view, and the ListView automatically handles scrolling and recycling of views
to efficiently display large datasets without consuming excessive memory. It's commonly used to present
lists of data in apps, such as contacts, messages, or other types of information.
Attributes:
41. android:id: Assigns a unique identifier to the ListView that can be used to reference it
programmatically.
2. android:layout_width and android:layout_height: Specifies the width and height of the ListView.
3. android:divider: Sets the drewable that will be used as a divider between items in the list.
Features of ListViev
4. Efficient Scrolling: The Li automatically handles scrolling and view recycling, allowing
smooth scrolling through large datasets without consuming excessive memory.
2. Custom Adapters: You can use custom adapters (eg, AmrayAdapter, CursorAdapter,
BaseAdapter) to bind data to the ListView and customize the appearance of individual lst ites.
3. Item Click Handling: The ListView allows you to set click listeners for individual items, enabling
youto respond to item clicks and perform actions based on user interactions.
4, Item Selection: The ListView supports single-choice and multiple-choice modes, allowing users to
select one or more items from the list.
5. Headers and Footers: You can add header and footer views to the ListView, which are separate
views that appear at the top and bottom of the lst
GridView:
A GridView is another versatile UI widget in Android that displays items in a grid, similar to a table or
matrix. t's used to present data in a two-dimensional arrangement, allowing you to create layouts that
show items in rows and columns. Each item in the GridView is represented by a view, and you can
‘customize the appearance of these views to create complex grid-based interfaces.
1. android:id: Assigns a unique identifier to the GridView that can be used to reference it
programmatically.
2. android:layout_width and android:layout_h
Gridview.
3. android:numColumns: Sets the number of columns inthe grid. You can set thisattribute to control
the layout of items in the grid.
Features of Grid View:
4. Grid Layout: GridView automatically arranges items in a grid, mal
in arow-and-column format
2. Customizable Appearance: You can customize the appearance of grid items by defining custom
layouts for each item, allowing you to display complex UI elements.
3. Scrollable: Like other scrollable views, GridView can handle a large number of items by allowing
users to scroll vertically to see more items.
4, Adapter-Based Data Binding: You can bind data to the GridView using an adapter (e.¢.,
BaseAdapter or custom adapters). Adapters handle data population and view recycling,
ht: Specifies the width and height of the
gt suitable for displaying data5. temClick Handling: You can set click listeners to hancle item clicks in the GridView, enabling user
interaction
RecycleView:
The RecyclerView is a more advanced and flexible version of the GridView and ListView widgets in
Android. It's designed to efficiently display large lists and grids of data while providing greater control over,
item layouts and interactions. The RecyclerView is partof the Ancroid Support ibrary and offers improved
performance, better customization options, and a more modular architecture.
Features:
4. Improved Performance: The RecyclerViewimplements a more efficient view recycling mechanism
compared to ListView and GridView, resulting in smoother scrolling and reduced memory usage.
2. LayoutManager: The RecyclerView introduces the concept of LayoutManager, which allows you
to control how items are laid out. You can choose from builtin layout managers like
inearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.
3. ViewHolder Pattern: The RecyclerView enforces the use of the ViewHolder pattern, which
optimizes memory usage by reusing views within the list or grid
4, Item Decoration: You can easily add decorations such as dividers, margins, and custom
decorations between items in the RecyclerView.
5. Item Animations: The RecyclerView supports builtin item animations, making it straightforward
to add smooth animations when items are added, removed, or updated.
6. Clickable and interactable: You can handleitem clicks, long clicks, ard other interactions with ease
using the RecyclerView.
7. Item Decoration: You can easily add decorations such as dividers, margins, and custom
decorations between items in the RecyclerView.
Attributes:
4. android:id: Assigns 2 unique identifier to the RecyclerView that can be used to reference it
programmatically.
2. android:layout_width and android:layout_h
RecyclerView.
ight: Specifies the width and height of the
Why recycle view is recommended over other view?
‘The ReeyderView is recommended over other views tke istVew and GridView due to its eshanced performance, fleibiliy, and
advanced features. t ofersa more modern and efficient way to display lists and grid of data in Android applications. Here's why
RecyclerView i preferred, explained with an example
1. Performance and Efciency: The RecyclerView introduces the concept of view recycling through the ViewHolder pattem,
Which minimizes memory usage and improves scrling performance, especially for large datasets. It euses views as the
ser scrlls, resuitingin smoother animations and reduced lag.
Example: imagine an app that dsplaysa list of mages. Using ListView, everytime you scrll, views are inflated and datas,
bound to them, leading to frequent object creation and destuction. With RecyclerView, the ViewHolder pattem ensures that
‘only alimited number of views are created, and these views ar reused for different ites as you sro
2. Flexibility ard Customization: The RecyclerView allows you to customize various aspects of tem layouts, interactions, and
animations providing greater control over the appearance and behavior of yeur ist ogi
Example: Suppose you want to create a social media feed where each post has a varying layout containing text, images, and
Videos. With ListView or GridView, creating sucha dynamic layout can be challenging. However, withthe RecyclerView, you can
use diferent vew types within the adapter to represent various pest layouts and customize each post's appearance.List View Vs Recycle View
Feature ListView RecyclerView
Less efficient due to limited view More efficient with advanced view recycling through the
Performance recycling \ViewHolder pattern
view ‘Advanced view recycling using ViewHolder pattern for
Recycling Basic view recycling improved performance
Limited layout managers (e.g, Various builtin layout managers. ((eg.,
layout LinearLayoutManager, LinearLayoutManager, GridLayoutManager,
Managers GridLayoutManager} StaggeredGridLayoutManager) for versatile layouts
Limited customization for item Greater customization and control over item layouts and
Flexibility layouts interactions
tem
|Animations Limited built-in animations Builtin support for smooth item animations
tem Enhanced support for item decoration, including dividers
Decoration Basic supportforitem decoration and custom decorations
Endless
Scrolling Requires custom implementation Easier implementation of endiess/infinite scrolling
List View Vs Grid View:
Purpose Displays items in a vertical list Displays items in a grid arrangement
layout Vertical scrolling Vertical scrolling
Number of Columns N/A Configurable number of columns
layoutManager N/A N/A
Adapter ArrayAdapter, Custom Adapter, etc. __ArrayAdapter, Custom Adapter, etc.
Layout for Items Single-item layout Single-item layout
Flexibility Limited customization of layout per item Limited customization of layout per item
item Click Handling Supports item clic listeners Supports item click listeners
Item Long Click Handling Supports item long click listeners Supports item long click listene
Grid View Vs Recycle View:
Purpose Displays itemsin agridarrangement _Displaysitesin various layouts
layout rid arrangement Flexible layouts (near, gi, staggered
Number of Columns Configurable numberof colums Configurable number of columns
LUneartayoutManager, GridiayoutManager,
layoutManager NYA StaggeredGridLayoutManager
Adapter ‘rrayAdapter, Custom Adapterjetc. RecycerView Adapter, Custom Adapt, ee
Layout forltems _ Single-item layout Customizable item layoutsLUmited custemization of layout per
[Bem clk Handing Supports tem click listenerx Supports item clcklteners
Unit -7
SQlite and its Features:
SQLite isa self-contained, serverless, and open-source relational database management system (RDBMS)
that focuses on simplicity, efficiency, and portability. It's designed for embedded systems and local storage,
making it an excellent choice for applications that need to store and manage structured data on a user's
device or within an application. SQLite is widely used in various software applications, including desktop
software, mobile apps, web browsers, and more.
Here are some key features and concepts of SQLite:
1
Self-Contained: SQLite is a standalone library that requires no separate server process or
configuration. The entire database system is implemented asa single disk file, which makes it easy
to manage and distribute.
Serverless: Unlike traditional client-server databases, SQLite operates in-process with the
application that uses it. This eliminates the need for network communication and simplifies setup.
Zero Configuration: Since SQLite is embedded within the application, there's no need to set upa
separate database server or manage complex configurations. The database engine is ready to use
as soon as you indude it in your application.
SQL Compatibility: SQLite supports the Structured Query Language (SQL), which is a standard
language for interacting with relational databases. This means you can create, modify, and query
your database using SQL statements.
‘Small Footprint: SQLite is designed to be lightweight and efficient, making it suitable for resource-
constrained environments such as mobile devices and embedded systems.
Cross-Platform: SQLite is cross-platform and supports various operating systems, including
Android, iOS, Windows, macOS, Linux, and more.
Advantages:
1
Lightweight and Embedded: SQLite is designed to be a lightweight and embedded database
engine. It operates within the same process as your application, eliminating the need for a
separate server process and simplifying deployment.
Zero Configuration: Since SQlite is a serverless database, there's no need for complex
configuration, setup, or administration. it's as simple as including the SQlite library in your
application
Self-Contained: An entire SQLite database is stored as a single file on the file system. This self-
contained nature makes it easy to manage and move around.
Cross-Platform Compatibility: SQLite is compatible with various operating systems, including
Android, iOS, Windows, macOS, Linux, and more. This cross-platform support is valuable for
applications that need torun on different devices,5. SQL Support: SQLite supports SQL, a widely-used language for managing and querying relational
databases, This makes it familiar to developers who are already familiar with SQLconcegts.
Disadvantages:
1. SQlite is used to handle low to medium traffic HTTP requests.
2. Database size is restricted to 268 in most cases.
SOlite vs SQL:
Aspect
Definition
Type
implementation
Deployment
Server-Client
Model
File-Based
Storage
Portability
Scalability
Performance
sat sQlite
SQL is a language used to manage relational SQlite is a self-contained, serverless,
databases, including creating, querying, embedded RDBMS that uses SQL as its
modifying, and administering them. query language.
SQlite s a specific database management
SQL is a language specification rather than a system that implements the SQL
specific database system. language.
Implemented by various database management
systems like MySQL, PostgreSQL, Oracle, Implemented as a standalone library that
Microsoft SQL Server, ete. can be embedded within applications.
Embedded directly within the
Requires 2 separate database server and client application's process. No separate server
application. required.
Follows a client-server model, where clients Does not use a client-server model; the
communicate with the database server over a database engine operates within the
network. application itself
Generally not file-based; data is stored in the Stores the entire database in a single file
database server. on the filesystem.
Generally more portable due to the
Code written in SQL might need adjustments to consistent SQlite implementation across
work across different database systems. platforms.
Suitable for applications with larger scale and More suitable for smaller-scale
high concurrency. applications or single-user scenarios.
Offers fast read and write performance
Performance can vary depending on the for local storage due to its embedded
database system and its configuration. natureEstablishing Connection:
Establishing a connection to an SQLite database in an Android application involves creating a subclass of
the SQLiteOpenHelper class and SQliteDatabase class and implementing its methods to manage database
creation, versioning, and opening. The SQLiteOpenHelper class is used for database creation and version
management. For performing any database operation, you have to provide the implementation of
onCreate() and onUpgrade() methods of SQLiteOpenHelper class.
Methods in SQliteOpenHelper class:
1. onCreate(SQliteDatabase db)
‘+ Called when the database is created for the first time.
‘+ You should create your database tables and initial data here.
2. onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ Called when the database needs to be upgraded, typically due to a version change.
‘You should handle schema changes and data migrations here.
3. onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ Called when the database needs to be downgraded, usually after a version rollback.
‘You should handle schema changes and data migrations for downgrades here.
4, getWritableDatabase()
‘+ Returns an instance of a writable SQLiteDatabase.
‘+ Use this method when you need to perform write (insert, update, delete) operations on
the database
Method In SQliteDatabase class:
41. Void execSQL(string sql)
Executes the sql query not select query. Basically used for creating database and tables.
2. Long Inser(string table, string nullColumntack, ContentValues values)
Inserts record on the database. The table specifies the table name, nullColumnHackdoes'tallow
completely null values. f second arguments null, android will store null valuesif values are empty.
The third argument specifies the values to be stored.
3. Int update(String table, ContenetValues values, String whereClause, String|] whereArgs)
Updates a row
4, Cursor rawQuery(String query, string[] selection Ags)
Returns a cursor over the result set.import [Link];
import [Link];
import [Link];
Public class DBHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "[Link]";
private static final int DATABASE_VERSION = 1;
private static final String CREATE_TABLE =
"CREATE TABLE my_table (°+
"id INTEGER PRIMARY KEY," +
“column_name TEXT)";
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
[Link](CREATE_TABLE);
}
@Override
public void onUpgrade|SQLteDatabase db, int oldVersion, int newVersion) {
|/ Manele database upgrades here
}
}Insert Data:
public long insertData(String data) {
DBHelper dbHelper = new DBHelper(this);
SOLiteDatabase database = [Link]\);
ContentValues values = new ContentValues();
[Link]{"column_name’, deta);
long newRowid = [Link]("my_table", null, values);
databaseclose();
return newRowld;
}
Update Data:
public int updateData(iong rowld, String newData) {
DeHelper dbHelper = new DBHelper(this);
SQLiteDatabase database = [Link]);
ContentValues values = new ContentValues);
[Link]("column_name", newData};
String selection ="_id = 2";
String[] selectionArgs = { String valueOf(rowld) };
int rowsUpdated = database update("my_table", values, selection, selectionArgs);
[Link]();
return rowsUpdated;
}
Select Data:
public ListeString> getAliDatal) {
ListeString> datalist = new Arraylist();
DBHelper dbHelper = new DBHelper'this);
SQLiteDatabase database = [Link]();
String[] columns = { "column_name" };
Cursor cursor = [Link]("my_table”, columns, null, null, null, null, null)
while ([Link]()) {
String data = cursorgetString(cursorgetColumnindex("column_name"));
[Link](data);
}
[Link]();
[Link]();
return dataList;
}Introduction to API
‘API is an abbreviation for Application Programming Interface which is a collection or communication
protocols and subroutines used by various programs to communicate between them. A programmer can
make use of various API tools to make its program easier and simplex .Also an API facilitates the
programmers with an efficient way to develop their software programs.
‘Thus in simpler terms, an API helps two programs or applications to communicate with each other by
providing them with necessary tools and functions. It takes the request from the user and sends it to the
servite provider and then again sends the result generated from the service provider to the desired user.
Types of API
1
Web APIs: A web [Link] known as Web Services is an extensively used over the web and can be
easily accessed using the HTTP protocols. A web API is an open source interface and can be used
by a large number of client through their phones tablets or pc.
2. Local API: In these types of API, the programmers get the local middleware services.
TAPI(Telephony Application Programming Interface), NET are common examples of Local API's.
3. Program API: It makes a remote program appears to be local by making use of RPC’s(Remote
Procedural Calls). SOAP is a well-known example of this type of API
Advantages:
‘Advantages of APIs:
1
5
Modularity and Reusability: APIs promote modular programming, allowing developers to build
applications by combining existing, tested, and well-cocumented components. This leads to code
reusability, ecucing development time and effort.
Efficiency: APIs provide a way to perform complex operations with justa few lines of code, saving
developers from having to implement intricate functionalities themselves.
Interoperability: APIs enable different software components, systems, ot services to work
together seamlessly, They facilitate integration between diverse technologies and platforms
Specialization: APIs allow developers to focus on their specific area of expertise. For example, a
front-end developer can use APIs to interact with back-end services without needing to
understand the internal workings of those services.
Third-Party Integration: APIs enable developers to integrate external services, tools, and
functionalitiesinto their applications without starting from scratch. This accelerates development
and enriches application capabilities.
Disadvantages:
2
Cost: Developing and implementing API is costly at times and requires high maintenance and
support from developers
Security: Using API's adds another layer of surface which is then prone to attacks and hence the
security risk problem is common in API’.Introduction to JSON:
JSON, which stands for "JavaScript Object Notation,” is a lightweight data interchange format commonly
Used to transmit data between a server and a web application, or between different parts of a software
system. JSON is human-readable and easy for both humans and machines to understand, making it a
popular choice for representing structured data.
Encoding and Decoding SON
Encoding:
[Link]
connect_error}{
die(“Connection failed:”.$conn->connect_error};
}
Iretrieving data
‘$sql="SELECT *form student”;
Sresult=$conn->query($sql);
Hencoding the data in json format
Sison=array()
M(Sresult-> num_rows>0,
While($row=$result->fetch_array()){
Sison{‘data"]
U-array(“sid’=>$row[“sid"],"name”=>$row[“name”],'address”=>$row{ “address”
}
}
Echo json_encode($json);
$conn->close();
>Decoding Json using in mobile application using Java
Public class DecodingiSON extends Activity{
@ Override
Protected void ontreate (Bundle b){
superonCreate(b}{
decodelson|);
}
public void decodelson(){
try
String paste json string
String json_data="{/n"+
JSONObject result=new JSONObject{json_data);
JSONArray data=[Link](“data);
for (int i=Oi
Step 2: Add your generated API key in your manifest file inside applicaton tag as follows
Step 3: Add following dependency in [Link] file.
dependencies
implementation’ com [Link]:play-services-maps:15
b
Step 4: Now create layout resource file to display google map.
xml version="1.0" encoding ="utf-8">
‘fragment xmlns:android-"hitp://schemas android com/apk/res/android"
xmlns:tools="http:/[Link]/tools"
android:layout_width="maich_parent”
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=" MapsActivity”
android:name="com,[Link] gms maps. SupportMapFragment" />
Step 5: MapsAct
public class MapsActivity extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedinstanceState);
setContentView(R layout activity_maps);
(/ Obtain the SupportMapFragment and get notified when the map is ready to be used.
‘SupportMapFragment mapFragment = (SupportMapFragment)
_getSupportFragmentManager().findFragmentByld(R. id map);
mapFragment getMapAsync(this),
5
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;,
LatLng sydney = new LatLng(-34, 151);
[Link](new MarkerOptions()
position(sydney){itle("Marker in Sydney");
[Link]([Link](sydney));
a
Procedure for Publishing Application in Google Play Store
Generating Signed APK for App Release
Following are the steps used to generate signed APK.
1, Go to menu and select Build->Generate Signed APK.
2. Now click Create new keyboard file. This keystore file is necessary to upload new app and
for updating existing app. If you have already created keystore file, then you can click
Choose existing keystore file.
3. Now fill up information for creating new keystore file and click ok.
4, Now select VI (jar Signature) and click finish, This will create signed APK for release.
5. Now click Event Log and locate to the folder where signed APK has been placed. You can
‘get your signed APK file inside release folder
Upload Signed APK in play store
1
Visit htps/[Link]/apps/publish/ to upload your app in play store.
Following page will be displayed.
Here you need to create your developer account for lifetime by paying $25 using your eredit card
‘There is no limitation for numbers of apps. You can upload multiple apps using a single account.
Once you've created developer acvount following page will be displayed on screen.
Click Create Application
Next, give your application a title and the default language. You will now be moved to the Store
listing screen,
In siore listing page you must everything related to how your app will look in the store
Following information must be added in this page
‘A short description of your application
A full description
Screenshots
Ahi resolution icon
A feature Graphic
‘The applications type and its category
‘Your email
‘Your privacy policy
Now go to the App Release page and click create release bution. Following page will be displayed
on sereen,
Next Click Content rating
‘After pressing the continue button you will be asked several questions regarding the content of your
application. Just follow them in order, filling one by one.
Last but no least , go to pricing and distribution page. Be aware to fill in all the required fields. In
this last page, you can decide on
‘© If your application will be free or not
‘© Which countries your application will be available to
© Ifitcontains ads
© User programs
‘After filling up all the information regarding store listings, content rating, pricing and distribution
etc. Now you can go to App Release page to publish your application, To publish app in play store
.clickRolfoutbutton,