Mobile Application Development
Mobile Application Development
● Mobile Platforms: The software operating system environments that control mobile
hardware. The dominant modern paradigms are Android (an open-source ecosystem
built on the Linux kernel) and iOS (Apple's proprietary, closed ecosystem).
● Phones vs. PDAs: Historically, devices were split. Personal Digital Assistants (PDAs)
were handheld computing tools built for data management (calendars, notes) but lacked
cellular modems. Modern smartphones represent the complete convergence of PDA
computing power with cellular connectivity.
● Android SDK: The software development kit containing libraries, tools, and
documentation needed to build Android apps. It relies heavily on components like
Activities, Services, Content Providers, and Broadcast Receivers, executing code
historically via the Dalvik Virtual Machine (DVM) and modernly via the Android
Runtime (ART) to handle resource management.
● iOS SDK: Apple's proprietary software development kit that uses Cocoa Touch
frameworks to construct applications using Swift or Objective-C.
1
● Java ME (Micro Edition): A legacy, lightweight Java framework designed for early,
resource-constrained feature phones before the advent of full mobile operating systems.
● Virtual Machines & Resource Management: Mobile operating systems use specialized
virtual machines to run applications in isolated sandboxes. This structure ensures that a
single app crash cannot take down the entire operating system while strictly managing
battery, memory, and CPU limits.
2
Based on the mobile application development frameworks outlined by Wei-Meng Lee, Reto
Meier, and Mark L. Murphy, here is the comprehensive structural guide for Unit-1:
Introduction to Mobile Applications and Android.
The Android platform is an open-source, Linux-based operating system designed primarily for
touchscreen mobile devices. Unlike closed ecosystems, Android provides an open development
environment, allowing engineers to write software using Java or Kotlin that directly interacts with
underlying device hardware via the Android Software Development Kit (SDK).
Applications run inside a managed runtime environment. In legacy versions (such as Android 4),
this was managed by the Dalvik Virtual Machine (DVM), while modern iterations use the
Android Runtime (ART). Each application executes inside its own sandboxed process,
ensuring that resource constraints or crashes in one application do not destabilize the rest of the
operating system.
+----------------------------------------------+
| [Link] |
+----------------------+-----------------------+
|
+-----------------+-----------+-----------+-------------------+
| | | |
v v v v
+--------------+ +--------------+ +---------------+ +---------------+
| Activities | | Services | | Broadcast | | Content |
| (UI Window) | | (Background) | | Receivers | | Providers |
+--------------+ +--------------+ +---------------+ +---------------+
I. Activities
● Definition: An Activity represents a single, focused screen with a user interface (UI). It
acts as the visual entry point for user interaction.
3
● Mechanics: An application typically consists of multiple activities that are loosely bound
together. For example, an email application might have one activity to display a list of
emails, a second activity to compose an email, and a third to read individual messages.
II. Services
User interfaces in Android are constructed using a hierarchy of View and ViewGroup objects. A
View is a visual widget drawn directly on the screen that users interact with.
4
● Button: A standard clickable interface component designed to listen for user touch
events. Developers attach an OnClickListener mechanism to it in code to trigger
specific backend business logic routines when pressed.
4. Alert Dialogs
An AlertDialog is a prominent, modal window that appears directly in front of the active Activity
view, forcing the application framework to pause background focus until the user acts on it.
+-------------------------------------------------------+
| [Icon] Title Area |
+-------------------------------------------------------+
| |
| Message Content Layer (Text description or warning) |
| |
+-------------------------------------------------------+
| [Negative] [Neutral] [Positive] | (Button Actions)
+-------------------------------------------------------+
1. Title Area: Displays a contextual heading along with an optional illustrative graphic icon.
2. Content Message Area: Displays a descriptive text block, a list of selectable
checkboxes/radio buttons, or a custom embedded view hierarchy.
3. Action Buttons: Supports up to three explicit semantic response triggers:
○ Positive Button: Confirms and executes the action (e.g., "OK", "Accept",
"Submit").
○ Negative Button: Cancels the prompt, returning to the app without saving
changes (e.g., "Cancel", "Deny").
○ Neutral Button: Postpones the decision flow (e.g., "Remind Me Later").
5
Layout containers are structural ViewGroup objects designed to control the spatial arrangement
of child elements on a mobile device screen.
6
● ProgressBar: A visual indicator that signals the status of a background operation. It can
be rendered as an indeterminate circular spinner or as a determinate linear progress bar
tracking exact completion percentages.
● AutoCompleteTextView: An enhanced EditText view that dynamically displays
filtered text suggestions in a dropdown menu as the user types, powered by an
underlying data adapter.
3. Picker Views
Picker views provide intuitive, error-free interfaces for selecting time and date metrics,
abstracting away manual text parsing challenges.
● TimePicker: An interface element allowing users to select a specific time of day in either
a 12-hour (AM/PM) format or a 24-hour clock matrix.
● DatePicker: A graphical calendar view that lets users select a valid day, month, and
year through a structured interface.
Adapter views display dynamic, repetitive datasets. They decouple visual layouts from
underlying data structures by using an Adapter (such as an ArrayAdapter or BaseAdapter)
to create individual view instances on demand.
● Tabs: A navigation paradigm that segments complex applications into distinct functional
screens, enabling users to swap interfaces by tapping top or bottom navigation items.
● TabActivity: A legacy Android container architecture that utilized a TabHost view and a
TabWidget control strip to display multiple activities or views within a single managed
window.
● Modern Context: In modern Android development, this legacy class has been replaced
by a combination of TabLayout, ViewPager2, and modular Fragments.
7
To maintain structural consistency and support dark mode variations across an entire
application, Android decouples look-and-feel configurations from layout code using XML files
located in the res/values/ directory.
XML
<!-- Contextual example of Style vs Theme declarations -->
<resources>
<!-- Style: Applied to a specific UI View widget -->
<style name="CustomTitleText">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#FF0000</item>
</style>
● Styles: A collection of layout formatting attributes (e.g., width, padding, font size, text
color) treated as a single reusable resource entity. Instead of duplicating properties
across multiple individual buttons, a style is declared once and applied to individual
views using the style="@style/Name" attribute.
● Themes: A theme is a style applied globally to an entire Activity or the complete
<application> layer within the [Link]. Themes override local
variables globally, defining universal properties like brand primary colors, window status
bars, background panels, and default text styling across all child widgets.
8
Android provides several options for developers to persist application data depending on data
privacy needs, data structures, and space requirements:
Adapters act as the crucial middle layer bridge connecting data sources (such as an array, a list,
or database results) directly to structural presentation components (ListView, GridView, or
Spinner). They iterate through the data collection, instantiate layout templates for each data
row, and bind the specific data values to individual view widgets.
ArrayAdapter
BaseAdapter
● The Framework: The common, abstract base implementation for all system view
adapters.
● Implementation: When an application requires a highly complex layout (such as a list
row containing an image, multiple checkboxes, and distinct button controls), developers
create a custom subclass extending BaseAdapter. It requires overriding four core
structural methods:
○ getCount(): Returns the total number of rows in the dataset.
○ getItem(int position): Fetches the data object at a specific index.
○ getItemId(int position): Returns the row ID or index hash of the item.
○ getView(int position, View convertView, ViewGroup parent):
Programmatically inflates, configures, and returns the custom view hierarchy for
9
a specific row, using view-recycling configurations (convertView) to preserve
system memory.
● Usage: Typically used to store persistent configurations, app settings, login states, or
high scores.
● The Mechanics: Modifying preferences requires entering a transactional editing state
using an inner [Link] object. Changes are batched and written
asynchronously to disk using .apply() to avoid stalling the application's primary
thread.
Java
// Contextual implementation archetype
SharedPreferences sharedPref = getSharedPreferences("AppSettings",
Context.MODE_PRIVATE);
[Link] editor = [Link]();
[Link]("Username", "admin_user");
[Link]("DarkModeEnabled", true);
[Link](); // Writes data asynchronously
For applications handling structured data that demands complex relationships, search logic, and
transactional durability, Android provides an embedded relational database engine.
10
migrations like dropping tables or running structural ALTER TABLE modifications
safely.
● Data Manipulations: Interacting with the database relies on two paradigms: executing
raw SQL commands (execSQL()) or using ContentValues maps along with wrapper
methods (insert(), update(), delete()). Query executions return a Cursor object,
which acts as a pointer interface allowing developers to iterate sequentially through the
resulting relational rows.
When applications handle raw, unformatted file streams (such as raw text assets, downloaded
documents, images, or audio clips), they write files directly to the physical storage file system
using standard Java I/O packages ([Link]).
Internal Storage
● Characteristics: Files written here are strictly private to the creating application. Other
apps cannot access these folders, and the system automatically purges these directories
when the application is uninstalled.
● Methods: Developers invoke context helpers like openFileOutput(String name,
int mode) to stream data out to disk, or use getFilesDir() to navigate the
application's internal file paths safely.
External Storage
Unit-4: Overview of Hybrid Mobile Applications
Development
Based on the frameworks laid out by Mahesh Panhala (Beginning Hybrid Mobile Application
Development) and Reto Meier, this unit covers the inner mechanics, architectural layers,
runtime environments, and core HTML5 APIs that power hybrid mobile applications.
11
1. How Hybrid Applications Work
A Hybrid Application bridges the gap between web development and native mobile
architecture. It runs as a single, cross-platform code application that can be deployed across
multiple operating systems while maintaining a unified code framework.
+-------------------------------------------------+
| Hybrid App Container (Native) |
| +-------------------------------------------+ |
| | UI / UX Layer (HTML5 / CSS3 / JS) | |
| +---------------------+---------------------+ |
| | |
| v |
| +---------------------+---------------------+ |
| | Web View / JavaScript Bridge (Runtime) | |
| +---------------------+---------------------+ |
+------------------------|------------------------+
| (Native API Bridging)
v
+-------------------------------------------------+
| Native OS Services (Camera, GPS, Storage) |
+-------------------------------------------------+
The Architecture
● The Container: At its core, a hybrid app is a native shell application compiled using
platform-specific SDKs (Android/iOS). Instead of building standard UI elements, it
embeds an invisible, full-screen WebView layout container.
● The Core Code: The user interface and business logic are written using standard web
technologies: HTML5 for structure, CSS3 for styling, and JavaScript for app execution
logic.
● The JavaScript Bridge: To access native hardware capabilities (e.g., camera,
accelerometer, file systems, geolocation), hybrid platforms utilize a communication
abstraction layer or Bridge (such as Apache Cordova/PhoneGap plugins). The
JavaScript layer executes a call that the bridge interceptor catches, translates into an
explicit native system command, executes on the device hardware, and returns the
result back to the web view.
To run uniformly across diverse device configurations, hybrid apps adapt their web containers to
match the underlying architecture of target mobile platforms:
12
iOS Layer
● On iOS platforms, the native shell wraps around Apple's optimized web rendering engine
framework—historically using UIWebView and modernly using WKWebView.
● It operates inside strict Apple sandbox security permissions, using performance
enhancements like Just-In-Time (JIT) JavaScript compilation to keep execution speeds
close to native code.
● In the legacy mobile framework defined in standard texts, the Windows Phone layer
deployed hybrid apps within a container built around the Internet Explorer Mobile
rendering engine (WebBrowser control).
● It adapted JavaScript event loops to match the platform's execution layer, translating
web gestures into Windows-compliant UI behaviors.
HTML5 serves as the core engine for hybrid application development, transforming static web
markup into a dynamic application environment through specialized APIs.
13
These APIs are native capabilities built directly into modern web rendering engine
specifications:
These advanced specifications are integrated into hybrid containers to give JavaScript direct
access to physical mobile hardware sensors:
● Geolocation API: Allows the application to query the device's physical location using
GPS, Wi-Fi triangulation, or cellular tower data via simple commands:
[Link]().
● Device Orientation / Motion API: Captures physical hardware inputs from the device's
built-in accelerometer and gyroscope sensors, enabling developers to build responsive,
motion-controlled user interfaces.
● Network Information API: Provides real-time information about the device's active
connection status (e.g., cellular data vs. local Wi-Fi, or offline states). This allows the
application to transition smoothly into offline operational modes when connectivity drops.
Mobile application development focuses on creating software for handheld and portable devices
like smartphones, tablets, and smartwatches. Grounded in the foundational frameworks
established by Wei-Meng Lee, Reto Meier, and Mark L. Murphy, here is an introduction to
mobile applications and the Android platform.
1. Overview of Mobile Applications
Mobile applications (apps) are designed to run on resource-constrained hardware with specific
input mechanisms (touchscreens, sensors) and variable network conditions. They generally fall
into three architectural categories:
● Native Applications: Built specifically for a single mobile operating system using
platform-native SDKs and languages (such as Java/Kotlin for Android or Swift for iOS).
They offer peak performance, access to native APIs, and deep hardware integration.
14
● Web Applications: Mobile-optimized websites accessed through a device's browser.
They run universally across platforms using standard web technologies (HTML5, CSS3,
JavaScript) but are restricted by browser sandboxing.
● Hybrid Applications: Apps built using web standards wrapped inside a native shell
(WebView). Frameworks like Apache Cordova use JavaScript bridges to allow web code
to interface with native device hardware.
2. What is Android?
Android is an open-source, Linux-based operating system designed primarily for touchscreen
devices. Key attributes include:
● Open Source & Customizability: Managed by Google and the Open Handset Alliance
(OHA), Android provides an open software stack that allows hardware manufacturers
and software developers to modify and extend system components.
● Multi-Device Scalability: Powers smartphones, tablets, televisions, wearables (Wear
OS), and automotive infotainment systems (Android Auto).
● Rich API Framework: Exposes extensive libraries through the Android SDK, allowing
developers to build feature-rich apps that interact directly with hardware sensors (GPS,
camera, accelerometer, Bluetooth).
3. The Android OS Architecture
The Android platform is structured into five distinct layer stacks, built from the bottom up:
+-------------------------------------------------------------+
| Applications Layer |
| (System Apps, User Apps, Pre-installed Apps) |
+-------------------------------------------------------------+
| Application Framework |
| (Activity Manager, Content Providers, View System) |
+------------------------------+------------------------------+
| Libraries (C/C++) | Android Runtime |
| (SQLite, WebKit, OpenGL) | (ART / Legacy Dalvik) |
+------------------------------+------------------------------+
| Hardware Abstraction Layer (HAL) |
+-------------------------------------------------------------+
| Linux Kernel |
| (Drivers for Camera, Display, Power, Memory) |
+-------------------------------------------------------------+
1. Linux Kernel: The fundamental base layer responsible for hardware drivers, low-level
memory management, process management, power management, and system security.
2. Hardware Abstraction Layer (HAL): Exposes standard interfaces that communicate
with device-specific hardware features (such as camera or audio modules) to
higher-level Java API frameworks.
3. Libraries & Android Runtime (ART): Includes native C/C++ libraries (SQLite for
databases, WebKit/Blink for browser rendering, OpenGL for graphics) and the execution
runtime.
15
4. Application Framework: Provides high-level Java classes and services that developers
use to build applications (e.g., WindowManager, NotificationManager).
5. Applications Layer: The top visual layer containing both native system applications
(Phone, Contacts, Settings) and third-party applications downloaded by the user.
4. The Core Building Blocks of Android Apps
As outlined by Mark L. Murphy and Reto Meier, an Android application is composed of four
primary, loosely coupled components defined in the central [Link] file:
● Activities: Represent individual visual screens featuring a graphical user interface (UI)
for direct user interaction.
● Services: Background components that perform long-running tasks without providing a
visible UI (e.g., streaming music or syncing data in the background).
● Broadcast Receivers: Components that listen to and respond to system-wide event
announcements (e.g., device booting completed, low battery warning, or incoming
network state changes).
● Content Providers: Managed data abstraction layers that safely share application data
across different apps (e.g., exposing the system contacts database to an email client).
5. Android Execution and Runtime Model
● Dalvik Virtual Machine (DVM): Legacy execution runtime (prominent in early Android
versions, including Android 4). It used Just-In-Time (JIT) compilation, translating Dalvik
Bytecode into machine code dynamically as the application executed.
● Android Runtime (ART): The modern runtime replacing DVM. ART uses
Ahead-Of-Time (AOT) compilation, compiling application bytecode directly into machine
executable code during installation. This improves application startup speeds, optimizes
memory usage, and enhances battery life.
● Application Sandboxing: Every Android application executes within its own isolated
Linux process and runtime instance. A failure or crash within one application process
cannot directly compromise the memory or stability of another.
16
v v v v
+--------------+ +--------------+ +-----------------+ +-----------------+
| Activities | | Services | | Broadcast | | Content |
| (Visual UI) | | (Background) | | Receivers | | Providers |
+--------------+ +--------------+ | (Event Listener)| | (Data Sharing) |
+-----------------+ +-----------------+
1. Activities
An Activity represents a single visual screen with a graphical user interface (UI) designed for
direct user interaction.
● Core Purpose: Acts as the window layer through which users interact with the
application (e.g., typing, tapping buttons, scrolling through lists).
● Key Characteristics:
○ An application usually contains multiple activities linked together via Intents (e.g.,
clicking an item in ListActivity launches a DetailActivity).
○ Every Activity has a strictly managed lifecycle governed by state transitions:
onCreate(), onStart(), onResume(), onPause(), onStop(), and onDestroy().
● Common Use Case: A user profile page, an email composition window, or a settings
configuration menu.
2. Services
A Service is a background component that performs long-running operations without providing
a user interface.
● Core Purpose: Offloads heavy processing or asynchronous execution from the main
(UI) thread so the user interface remains smooth and responsive.
● Key Characteristics:
○ Started Services: Initiated by an app component calling startService(). Once
started, a service can run indefinitely in the background even if the user switches
to another application.
○ Bound Services: Initiated via bindService(), offering a client-server style
interface that lets components interact with the service, send requests, or retrieve
results.
● Common Use Case: Playing audio in the background while the user navigates other
apps, downloading files from a web server, or fetching continuous location updates.
3. Broadcast Receivers
A Broadcast Receiver is an event listener that enables an application to listen for and respond
to system-wide broadcast announcements or intents.
● Core Purpose: Acts as an asynchronous messaging hub, allowing apps to react to
events triggered by the Android OS or other third-party applications.
● Key Characteristics:
○ Broadcast Receivers do not feature a user interface. However, they can create
status bar notifications or trigger background services when an event is
intercepted.
○ Receivers can be declared statically in the [Link] or registered
dynamically in code using registerReceiver().
17
● Common Use Case: Reacting to system events like ACTION_BOOT_COMPLETED
(device finishing bootup), low battery warnings, incoming SMS messages, or changes in
network connectivity.
4. Content Providers
A Content Provider manages access to a central, structured data repository, enabling secure
data sharing across independent application processes.
● Core Purpose: Encapsulates application data and provides a unified interface for
cross-app data queries, updates, and transactions without exposing the underlying
storage mechanism (like an SQLite database, flat files, or local caches).
● Key Characteristics:
○ Interactions are performed using a standardized SQL-style URI syntax handled
by a ContentResolver object.
○ Exposes standard CRUD operations: query(), insert(), update(), and delete().
● Common Use Case: Accessing the system's native ContactsContract database to pick
a phone contact, reading media files via MediaStore, or sharing user preference data
securely between two separate enterprise apps.
Architectural Comparison Matrix
Component UI Primary Lifetime Trigger
Attached? Responsibilities
18
In Android UI development, every interface element is a subclass of the fundamental View
class. While complex layouts use containers, basic Views and Dialogs handle the core user
interactions like displaying text, accepting input, listening for clicks, and presenting pop-up
alerts.
1. Toast
A Toast is a lightweight, transient pop-up message used to provide quick feedback about an
operation without interrupting the user's current activity.
● Key Characteristics:
○ Non-modal: It floats above the app interface without grabbing focus or blocking
touch events.
○ Self-dismissing: Automatically disappears after a specified display duration
(Toast.LENGTH_SHORT or Toast.LENGTH_LONG).
○ Cannot receive user clicks or text input.
● Standard Usage:
● Java
[Link](context, "File saved successfully!", Toast.LENGTH_SHORT).show();
●
●
2. TextView
A TextView is the foundational UI widget engineered to display read-only or styled text on the
screen.
● Key Characteristics:
○ Acts as the parent superclass for many interactive widgets, including EditText
and Button.
○ Supports dynamic formatting such as custom fonts, sizes (sp), colors, text
alignments, and HTML parsing.
● Essential XML Attributes:
○ android:text="Hello World": Sets the display string.
○ android:textSize="18sp": Controls font size.
○ android:textColor="#333333": Sets font color.
3. EditText
An EditText is a direct subclass of TextView configured to accept keyboard input from the user.
● Key Characteristics:
○ Editable text box that automatically opens the soft virtual keyboard when tapped.
○ Uses input filters to enforce specific data formats (such as passwords, email
addresses, numbers, or multi-line text).
● Essential XML Attributes:
○ android:hint="Enter your name": Displays temporary watermark text when the
field is empty.
○ android:inputType="textPassword": Masks characters with dots and adjusts the
keyboard layout accordingly.
4. Button
A Button is a clickable user interface widget designed to initiate a specific action when pressed.
19
● Key Characteristics:
○ Subclass of TextView, meaning it shares text formatting properties alongside
custom visual states (default, pressed, focused).
○ Executes business logic by attaching an OnClickListener mechanism in
Java/Kotlin.
● Standard Usage:
● Java
Button submitBtn = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
// Action logic here
}
});
●
●
5. Alert Dialog
An AlertDialog is a modal prompt window that overlays the active Activity, pausing user
interaction with the background UI until a choice is made or the dialog is dismissed.
+-------------------------------------------------------+
| [Icon] Title Area |
+-------------------------------------------------------+
| Message Content Area |
| "Are you sure you want to delete this file?" |
+-------------------------------------------------------+
| [CANCEL] [DELETE] |
| (Negative Button) (Positive Button) |
+-------------------------------------------------------+
● Key Characteristics:
○ Constructed using the builder pattern ([Link]).
○ Composed of up to three customizable structural areas:
1. Title Area: An optional header title and illustrative graphic icon.
2. Content Area: Displays detailed message text, a list of choices, or a
custom XML view hierarchy.
3. Action Buttons: Provides up to three button triggers:
■ Positive: Confirms the action (e.g., "OK", "Submit").
■ Negative: Cancels the action (e.g., "Cancel").
■ Neutral: Postpones the decision (e.g., "Remind Me Later").
Quick Comparison
View Interactive? Modality Primary Function
Element
20
Toast No Non-modal Display brief, passive status
(Overlay) messages
21
● Fragment: A modular, reusable UI component running inside an Activity. Fragments
have their own independent lifecycle and UI layouts, making them essential for building
flexible interfaces across phones and tablets.
2. Specialized UI Views & Input Widgets
● ImageButton: A clickable view that displays an image graphic instead of text. It
responds directly to standard touch events (OnClickListener).
● CheckBox: A two-state selection button that can be checked or unchecked. Unlike radio
buttons, multiple checkboxes can be selected independently within the same view group.
● ToggleButton: Displays a dual-state button that visually toggles between "ON" and
"OFF" states, changing its background style according to its state.
● RadioButton & RadioGroup: A RadioButton is a two-state selection item. When
nested inside a RadioGroup, it enforces mutual exclusion—selecting one radio button
automatically deselects all others in that group.
● ProgressBar: Provides visual feedback to users during background operations. It can
be rendered as an indeterminate circular spinner (unknown duration) or a determinate
horizontal bar showing completion percentages.
● AutoCompleteTextView: An EditText view that dynamically displays a dropdown list of
matching text suggestions as the user types, powered by an underlying Adapter.
3. Picker Views
Pickers provide pre-built, standardized UI controls for selecting time and date metrics without
requiring manual text parsing.
● TimePicker: Allows users to select hours, minutes, and AM/PM parameters using either
a clock dial or a spinner control in 12-hour or 24-hour formats.
● DatePicker: Displays an interactive calendar interface allowing users to select a valid
day, month, and year.
4. Adapter Views (Lists & Grids)
Adapter views display dynamic datasets by using an Adapter (e.g., ArrayAdapter,
BaseAdapter) to create and recycle item rows on demand.
● ListView: Displays a vertically scrollable, single-column list of items. It uses view
recycling (convertView) to reuse off-screen views and conserve system memory.
● GridView: Arranges items in a two-dimensional, scrollable grid with custom numbers of
rows and columns (commonly used for image galleries).
● Gallery: A legacy horizontally scrollable widget that snaps items to the horizontal center
of the screen as the user swipes.
5. Tabs and Tab Navigation
● Tabs: A UI layout pattern that organizes complex applications into separate functional
screens accessible via tab headers.
● TabActivity: A legacy Android container class that hosted a TabHost and TabWidget
control strip to swap between views or activities within a single window frame.
● Modern Standard: Today, tabbed interfaces are built using TabLayout paired with
ViewPager2 and modular Fragments.
22
6. Android Styles & Themes
Android separates visual appearance from structural layout code using XML files inside the
res/values/ directory.
Attribute Scope Primary Purpose XML Declaration Example
Android handles data persistence through several distinct storage mechanisms, depending on
the data structure, privacy requirements, and file size. Grounded in the core Android concepts
outlined by Wei-Meng Lee, Reto Meier, and Mark L. Murphy, here is a comprehensive
breakdown of Android data handling.
1. Overview of Android Data Storage
Android provides five primary options for persisting application data:
1. SharedPreferences: Stores primitive data in key-value pairs (XML files).
2. Internal Storage: Saves private files directly on the device's internal file system.
3. External Storage: Saves files on shared public media or SD cards.
4. SQLite Database: Stores structured relational data in a private database file.
5. Network Connection: Persists data on external web servers via APIs.
2. Adapters: ArrayAdapter & BaseAdapter
23
An Adapter acts as an intermediary bridge between a data source (such as an array, list, or
database result) and a visual component (ListView, GridView, or Spinner). It iterates through
the dataset, inflates item views, and binds individual data items to UI widgets.
+-------------------+ +-------------------+ +-------------------+
| Data Source | ====> | Adapter | ====> | UI Container |
| (ArrayList / SQL) | | (ArrayAdapter / | | (ListView / |
| | | BaseAdapter) | | GridView) |
+-------------------+ +-------------------+ +-------------------+
ArrayAdapter
● Best For: Simple datasets (such as an array of strings or wrapper objects).
● Behavior: Reads each data item, converts it to a string by calling .toString(), and injects
it into a simple TextView layout (such as [Link].simple_list_item_1).
BaseAdapter
● Best For: Complex, highly customized layout rows containing multiple interactive
widgets (images, buttons, checkboxes).
● Behavior: An abstract class requiring developers to override four core methods:
○ getCount(): Returns the total number of items in the dataset.
○ getItem(int position): Retrieves the data object at a specific index.
○ getItemId(int position): Returns the unique row ID/index for an item.
○ getView(int position, View convertView, ViewGroup parent): Inflates the
custom XML layout and binds data to specific row views (typically using the
ViewHolder pattern for performance).
3. SharedPreferences: Saving Key-Value Data
SharedPreferences provides a lightweight framework to persist primitive data types (boolean,
float, int, long, String) as key-value pairs inside a private XML file located in the application's
data directory (/data/data/<package_name>/shared_prefs/).
● Common Uses: Saving user preferences, application settings, login flags, or user
session state.
● Writing Data: Requires requesting an editor object via .edit(), writing data using .putX()
methods, and saving the changes with .apply() (asynchronous, non-blocking) or
.commit() (synchronous, blocking).
Java
// Saving data
SharedPreferences sharedPref = getSharedPreferences("UserPrefs", Context.MODE_PRIVATE);
[Link] editor = [Link]();
[Link]("username", "john_doe");
[Link]("is_logged_in", true);
[Link](); // Asynchronous write
// Reading data
String username = [Link]("username", "default_user");
boolean isLoggedIn = [Link]("is_logged_in", false);
24
4. Storing Data in a Database (SQLite)
For structured data requiring complex queries, relations, and transactional integrity, Android
embeds a lightweight, serverless relational database engine called SQLite.
SQLiteOpenHelper
Android provides the SQLiteOpenHelper abstract class to manage database creation, version
management, and schema changes. Developers subclass it and override two mandatory
lifecycle methods:
● onCreate(SQLiteDatabase db): Called when the database is created for the first time.
Executes raw DDL statements (e.g., CREATE TABLE).
● onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion): Called when the
database version number increases. Manages schema migrations (e.g., ALTER TABLE
or DROP TABLE).
Java
public class DatabaseHelper extends SQLiteOpenHelper {
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_USERS_TABLE = "CREATE TABLE users (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"name TEXT, " +
"email TEXT)";
[Link](CREATE_USERS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
[Link]("DROP TABLE IF EXISTS users");
onCreate(db);
}
}
25
Java
// Inserting a record
ContentValues values = new ContentValues();
[Link]("name", "Alice");
[Link]("email", "alice@[Link]");
[Link]("users", null, values);
// Querying records
Cursor cursor = [Link]("SELECT * FROM users", null);
if ([Link]()) {
do {
String name = [Link]([Link]("name"));
// Process data
} while ([Link]());
}
[Link](); // Always close cursors to prevent memory leaks
26
Common openFileOutput(), getExternalFilesDir(),
API getFilesDir(), [Link]()
getCacheDir()
Hybrid mobile application development combines standard web technologies (HTML5, CSS3,
and JavaScript) with a native app shell. Based on the hybrid development architectures outlined
by Mahesh Panhala, here is a detailed breakdown of platform execution layers, browser
runtime environments, and HTML5 APIs.
1. Platform-Specific Execution Layers
A hybrid app relies on the host operating system's native container to render its web content
and translate JavaScript commands into native API calls.
+-------------------------------------------------------------------+
| Hybrid Native App Shell |
| +-------------------------------------------------------------+ |
| | UI Layer (HTML5 / CSS3 / JS) | |
| +------------------------------+------------------------------+ |
| | |
| v |
| +------------------------------+------------------------------+ |
| | Platform Web Runtime (WebView) | |
| | (iOS: WKWebView | Android: Android WebView | Win: IE) | |
| +------------------------------+------------------------------+ |
| | |
| v |
| +------------------------------+------------------------------+ |
| | JavaScript Native Bridge | |
| +------------------------------+------------------------------+ |
+---------------------------------|---------------------------------+
|
v
27
+-------------------------------------------------------------------+
| Native Hardware & OS Services |
| (Camera, GPS, Storage, Bluetooth, Contacts) |
+-------------------------------------------------------------------+
iOS Layer
● Engine: Renders web assets using Apple’s WebKit framework (WKWebView, replacing
legacy UIWebView).
● Security & Execution: Operates within Apple's strict application sandbox. It uses
Just-In-Time (JIT) compilation in modern runtimes to ensure web view performance
approaches native speeds.
● Distribution: Compiled via Xcode into a standard .ipa installer package distributed
through the Apple App Store.
Windows Phone Layer (Historical Academic Context)
● Engine: Relies on an embedded Internet Explorer Mobile rendering component
(WebBrowser control).
● Bridge: Translates JavaScript calls into C#/XAML background processes through the
platform’s native runtime host.
● Distribution: Packaged into .xap or .appx deployment bundles.
2. Browser-Based Applications vs. Browser Runtime
(WebView)
Feature Browser-Based Mobile App Hybrid App Browser Runtime
(WebView)
28
Distribution Hosted on a web server; Packaged as a native binary;
accessed via a URL. installed via App Stores.
29