1.1 Summary
This report analyzes the provided Java and XML files for an Android
application named PharmacyApp. The application is designed to manage
a simple list of prescriptions, allowing users to add new prescriptions
and view the details of existing ones. The architecture follows the
standard Activity-Database Helper pattern, utilizing SQLite for local
data persistence. The main screen displays a list of patients, serving as
the entry point for viewing or adding prescription records.
1.2 Project Overview and Scope
The PharmacyApp is a basic demonstration of CRUD (Create, Read,
Update, Delete) operations, though only Create (Insert) and Read
(Retrieve) functionalities are fully implemented.
Component Description Files Involved
Data Layer Manages the local DatabaseHelper.java
SQLite database.
Presentati Handles the User MainActivity.java,
on Layer Interface and user AddPrescriptionActivity.java,
interaction. ViewPrescriptionActivity.java
UI Defines the layout activity_main.xml,
Resources and appearance of activity_add_prescription.xml,
the screens. activity_view_prescription.xml
The application's primary goal is to provide a user-friendly interface for
pharmacy staff to quickly log and retrieve prescription information.
2.1 Database Structure (DatabaseHelper.java)
The application uses a single SQLite database file named pharmacy.db
with a version of 1. All data is stored in a single table named
prescriptions. The DatabaseHelper class, extending SQLiteOpenHelper,
manages the creation and upgrade of this database.
Table Definition: prescriptions
, Column Type Constraint Description
Name
id INTEGE PRIMARY KEY Unique identifier for each
R AUTOINCREMENT prescription record.
patient TEXT N/A The full name of the
patient.
medicine TEXT N/A The name of the
prescribed medicine.
dosage TEXT N/A The detailed dosage
instructions.
The SQL statement used for table creation is:
CREATE TABLE prescriptions(id INTEGER PRIMARY KEY
AUTOINCREMENT,patient TEXT,medicine TEXT,dosage TEXT)
2.2 Data Operations
The DatabaseHelper provides two core methods for data manipulation:
1. insertPrescription(String patient, String medicine, String
dosage):
o Uses a ContentValues object to securely map column names
to data.
o Invokes db.insert().
o Returns true on successful insertion (i.e., if the returned row ID
is not -1).
2. getAllPrescriptions():
o Uses a raw SQL query ("SELECT * FROM " +
TABLE_PRESCRIPTIONS) to fetch all columns and rows.
o Returns a Cursor object, which is then processed by
MainActivity to populate the list view.
3.1 Main Activity (MainActivity.java and activity_main.xml)
The MainActivity acts as the application's dashboard and read-view for
all prescriptions.
Layout (activity_main.xml)
The layout is a simple vertical LinearLayout containing:
1. A Button (@id/btnAdd) labeled "Add Prescription" for navigation.