A Mini Project Report on
STUDENT PROFILES Submitted to the Jawaharlal Nehru Technological University, Hyderabad In Partial Fulfilment of the Requirements for the award of the Degree of
Bachelor of Technology In Computer Science and Engineering By
Saurabh Kapoor
: 13WJ1A05P0
S Sathvi Reddy
: 13WJ1A05N9
S Balwinder Kaur
: 13WJ1A05N7
Under the Esteemed Guidance of
Mr. V. Devasekhar Associate Professor Department Of Computer Science Engineering
! DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING GURU NANAK INSTITUTIONS TECHNICAL CAMPUS (AUTONOMOUS) School of Engineering and Technology, Ibrahimpatnam , R.R District 501506 2016-17
i
GURU NANAK INSTITUTIONS TECHNICAL CAMPUS (AUTONOMOUS) School of Engineering and Technology Department of Computer Science & Engineering
CERTIFICATE This is to certify that this project report entitled “STUDENT PROFILES” by SAURABH KAPOOR (13WJ1A05P0) , SATHVI REDDY(13WJ1A05N9)
&
BALWINDER KAUR(13WJ1A05N7) submitted in partial fulfilment of the requirements for the degree of Bachelor of Technology in Computer Science and Engineering of the Jawaharlal Nehru Technological University, Hyderabad during the academic year 2016-2017, is a bonafide record of work carried out under our guidance and supervision.
INTERNAL GUIDE
PROJECT CO-ORDINATOR
HOD CSE-2
Mr. V. Devasekhar
Ms. V. Swathi
Mr. V. Devasekhar
EXTERNAL EXAMINER
ii
ACKNOWLEDGEMENT
We specially thank our internal guide Mr. V. Devasekhar, Associate Professor, Department of CSE, for his suggestions and constant guidance in every stage of the project.
We would like to say our sincere thanks to Mrs .V.Swathi, Assistant Professor, Department of CSE, Mini Project Coordinator, for providing seamless and right suggestions are given in the development of the project.
We have been truly blessed to have a wonderful adviser Mr. V. Devasekhar, HOD -2 CSE, GNITC for guiding us to explore the ramification of our work and we express my sincere gratitude towards him for leading me thought the completion of Project.
We wish to express our sincere thanks to Dr. Rishi Sayal, Associate Director, GNITC for providing us the conductive environment for carrying through our academic schedules and Project with ease.
SAURABH KAPOOR (13WJ1A05P0) S SATHVI REDDY (13WJ1A05N9) S BALWINDER KAUR(13WJ1A05N7)
iii
ABSTRACT Android is a mobile operating system (OS) currently developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. Android's interface is mainly based on direct manipulation, using touch gestures that loosely correspond to real-world actions, such as swiping, tapping and pinching, to manipulate on-screen objects, along with a virtual keyboard for text input. In addition to touchscreen devices, Google has further developed Android TV for televisions, Android Auto for cars, and Android Wear for wrist watches, each with a specialised interface. Variants of Android are also used on notebooks, game consoles, digital cameras, and other electronics. This project focuses on developing a mobile application that is developed using Android Studio , Android Standard Development Kit(SDK) , Android APIs. The aim of our mini project is to develop a mobile application which contains information about the students and their parents.This would help the faculty to easily communicate with the students and their parents whenever required. The faculty would be able to the student and their parents through text , mail or phone as per their need.This would also be modified further in the future stages into a application in which faculty would be able to use features such as internet messaging and internet calling. The main part of the project resides on the mobile phone which has application that is developed using Android Studio.
4! | P a g e
iv
TABLE OF CONTENTS ________________________________________________________________________________
Contents
Page No.
Abstract……………………………………………………………………………………
4iv
1. INTRODUCTION
7-9
1.1 Motivation……………………………………………………………………………. 1.2 Problem Definition…………………………………………………………………… 1.3 Objective of the Project………………………………………………………………. 1.4 Limitations of the Project……………………………………………………………..
2. LITERATURE SURVEY
10 - 20
2.1 Introduction………………………………………………………………………….. 2.2 Review of related literature from related Research Paper……………………………….. 2.3 Overview of Android Platform ……………………………………………………… 2.4 Android Architecture………………………………………………………………... 2.5 What is SQlite……………………………………………………………………….. 2.6 Using the SQlite Database…………………………………………………………... 2.7 Other Databases……………………………………………………………………... 3. ANALYSIS
21 -23
3.1 Introduction………………………………………………………………………….. 3.2 Existing System……………………………………………………………………… 3.3 Limitations of Existing System……………………………………………………… 3.4 Proposed System…………………………………………………………………….. 3.5 Advantages of Proposed System…………………………………………………….. 3.6 Hardware Requirements……………………………………………………………... 3.7 Software Requirements ……………………………………………………………...
5! | P a g e
v
4. SYSTEM DESIGN
24 - 32
4.1 Design Details……………………………………………………………………….. 4.1.1 Data Flow Diagram……………………………………………………………... 4.2 Modeling…………………………………………………………………………….. 4.2.1 Use case Diagram with caption and description……………………………….. 4.2.2 Class Diagram with caption and description…………………………………… 4.2.3 Object Diagram with caption and description………………………………….. 4.2.4 Component Diagram with caption and description……………………………. 4.2.5 Deployment Diagram with caption and description……………………………
5. IMPLEMENTATION
33 - 65
5.1 Modules……………………………………………………………………………… 5.2 Modules Description………………………………………………………………… 5.3 Technologies Used………………………………………………………….………. 5.4 Sample Source code …………………………………………….…………………. 5.5 Screen Shots………………………………………………………………..……….. 5.4.1 Src1 with caption and description and citation in the text…………………... 5.4.2 Src2 with caption and description and citation in the text………….……….. 5.4.3. Src3 with caption and description and citation in the text………………….. 5.4.4 Src4 with caption and description and citation in the text………….……….. 5.4.5 Src5 with caption and description and citation in the text……….………….. 6. TESTING
66 - 69
6.1 Narration of each testing method applied specific to the project only and not in general………………………………………………………………………. 6.2 Test cases in detail…………………………………………………………………. 6.3 Tests reports Module wise with description………………………………………..
7. CONCLUSION ………………………………………………………………………
70
8. FUTURE SCOPE ……………………………………………………………………..
70
6! | P a g e
vi
CHAPTER 1 INTRODUCTION
7! | P a g e
1
1.1 MOTIVATION As we know that now a day’s most of communication is mobile based communication so we want to do an application in mobile platform. By observing all the mobile operating systems we found that Android is the most used operating system. So we selected this project to have some knowledge on the latest platform (ANDROID), current technologies which are going on now and want to design a Good application.
1.2 PROBLEM DEFINITION One of the fastest growing industries now a day is mobile industry. There are many competitors in this area who are doing research and development on new platforms & experience. One such technology is Android from Google which is ed for many manufactured phones. One of the fastest growing industries now a day is mobile industry. There are many competitors in this area who are doing research and development on new platforms & experience. One such technology is Android from Google which is ed for many manufactured phones. These phones are described as next Generation mobiles [As described by Google]. The project is develop a mobile application
which provides information
about a student and their parents .This application will also be used as base for further modification in which it would be used to manage the complete details of each and every member of the college .
1.3 OBJECTIVE OF THE PROJECT The main objective of the project is to help the faculty by providing details of the students and also their parents in-order to improve the communication between them.
1.4 LIMITATIONS OF THE PROJECT The limitation related with this project is that this application charges money inorder to make a call or to send a message according to our network provider . 8! | P a g e
2
CHAPTER 2 LITERATURE SURVEY
9! | P a g e
3
2.1 LITERATURE SURVEY Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. The Android SDK includes a comprehensive set of development tools. These include a debugger, libraries, a handset emulator (based on QEMU), documentation, sample code, and tutorials. Currently ed development platforms include x86-architecture computers running Linux (any modern desktop Linux distribution), Mac OS X 10.4.8 or later, Windows XP or Vista. The officially ed integrated development environment (IDE) is Eclipse (3.2 or later) using the Android Development Tools (ADT) Plug in, though developers may use any text editor to edit Java and XML files then use command line tools to create, build and debug Android applications. By observing all the mobile operating systems we found that Android is the most used operating system. So we selected this project to have some knowledge on the latest platform (ANDROID), current technologies which are going on now and want to design a Good application. World is contracting with the growth of mobile phone technology. As the number of s is increasing day by day, facilities are also increasing. Starting with simple regular handsets which were used just for making phone calls, mobiles have changed our lives and have become part of it. Now they are not used just for making calls but they have innumerable uses and can be used as a Camera , Music player, Tablet PC, T.V. , Web browser etc Android comes with an Android market which is an online software store. It was developed by Google. It allows Android s to select, and applications de! |Page 10
veloped by third party developers and use them. There are around 2.0 lack+ games, application and widgets available on the market for s. Android applications are written in java programming language. Android is available as open source for developers to develop applications which can be further used for selling in android market. There are around 200000 applications developed for android with over 3 billion+ s. Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. For software development, Android provides Android SDK (Software development kit)
APPLICATIONS : These are the basics of Android applications: •
Android applications are composed of one or more application components (ac-
tivities, services, content providers, and broadcast receivers) •
Each component performs a different role in the overall application behaviour,
and each one can be activated individually (even by other applications) •
The manifest file must declare all components in the application and should also
declare all application requirements, such as the minimum version of Android required and any hardware configurations required •
Non-code application resources (images, strings, layout files, etc.) should in-
clude alternatives for different device configurations (such as different strings for different languages) 2.2 REVIEW OF RELATED LITERATURE FROMRELATED RE-SEARCH PAPER Creating and Using Databases for Android Applications Android is an open source software assemble of an operating system, middleware and key applications for mobile devices introduced by Google capable of running multiple application programs. It is a complete operating environment based upon the Lin! |Page 11
ux® V2.6 kernel. Initially, the deployment target for Android was the mobile-phone arena such as smart phones and low-cost flip-phone devices. Android platform is produced to make new and innovative mobile application program for the developers to make full use of all functions connected to handset internet. As a complete mobile platform, Android provides universal set of powerful Operation System, Comprehensive Library Set, abundant Multimedia Interface and Phone Application. The data-storage burden is eased because the Android platform includes the popular open source SQLite database. SQLite is a software library that implements a SQL engine. It has been used with great success as on-disk file format: allows the developer to handle data in a simple way, but also have the use of database features (such as undo, redo, etc.). In embedded device environment, in which there is low-concurrency and there are little or medium size datasets, SQLite is the right choice. In this paper, we discuss the overview of the android platform, it architecture and the android applications. The data storage for Android featuring the SQLite database was also discussed.
2.3 OVERVIEW OF THE ANDROID PLATFORM Android is a set of software for mobile devices including Operation System, Middleware and Core Application, and a new Mobile Platform of Google. It is a complete mobile platform based on LINUX 2.6 Kernel that provides universal set of powerful Operation System, Comprehensive Library Set, abundant Multimedia Interface and Phone Application. Android platform is produced to make new and innovative mobile application program for the developers to make full use of all functions connected to handset internet. The Android platform was developed by Google and later the Open Handset Alliance (OHA). The Open Handset AllianceTM is a group of mobile and technology companies who come together to accelerate innovation in mobile and offer consumers a richer, less expensive, and better mobile experience for consumers. ! |Page 12
The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. Android is a multi-process system in which each application (and parts of the system) runs its own process. Security between applications and the system is enforced at the process level through standard Linux facilities such as and group IDs that are assigned to applications. Additional finer-grained security features are provided through a “permission” mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data.
2.4 ANDROID ARCHITECTURE Linux Kernel. Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack Libraries. Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. SYSTEM C LIBRARY - a BSD-derived implementation of the standard C system library(libc), tuned for embedded Linux-based devices
MEDIA LIBRARIES - based on PacketVideo's OpenCORE; the libraries playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG SURFACE MANAGER - manages access to the display subsystem and seamlessly computes 2D and 3D graphic layers from multiple applications
! |Page 13
LIBWEB CORE - a modern web browser engine which powers both the android browser and embeddable view
SGL- the underlying 2D graphics engine
3D LIBRARIES - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer. SQLITE - a powerful and lightweight relational database engine available to all
applications Android Runtime.
! |Page 14
DALVIK VIRTUAL MACHINE:Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. APPLICATION FRAMEWORK: By providing an open development platform, Android offers developers the ability to build extremely rich and innovative applications.
An Android application consists of one or more of the following classifications :
! |Page 15
ACTIVITIES : An application that has a visible UI is implemented with an activity.When a selects an application from the home screen or application launcher, an activity is started. SERVICES : A service should be used for any application that needs to persist for a long time, such as a network monitor or update-checking application.
CONTANT PROVIDERS : You can think of content providers as a database server. A content provider's job is to manage access to persisted data, such as a SQLite database. If your application is very simple, you might not necessarily create a content provider. If you're building a larger application, or one that makes data available to multiple activities or applications, a content provider is the means of accessing your data.
BROADCAST RECIEVERS : An Android application may be launched to process a element of data or respond to an event, such as the receipt of a text message.
An Android application along with a file called AndroidManifest.xml is deployed to a device. The AndroidManifest.xml contains the necessary configuration information properly installed to the device. It includes the required class names and types of events the application is able to process, and the required permissions the application needs to run. For example, if an application requires access to the network — to a file, for example — this permission must be explicitly stated in the manifest file. Many applications may have this specific permission enabled. Such declarative security helps reduce the likelihood that a rogue application can cause damage on your device.
The lifeline for every Android application is its database . A database system is needed to store structured data, unless the application deals only with simple data. Android uses the SQLite database system, which is an opensource, stand-alone SQL database, widely used by many popular applications. ! |Page 16
SQLite is a lightweight transactional database engine that occupies a small amount of disk storage and memory, thus, it is a perfect choice for creating databases on many mobile operating systems such as Android and iOS.
The database that is created for an application is only accessible to itself; other applications will not be able to access it. Once created, the SQLite database is stored in the /data/data/<package_name>/databases folder of an Android device.
2.5 WHAT IS SQLITE ? SQLite is an Open Source Database which is embedded into Android. SQLite s standard relational database features like SQL syntax, transactions and prepared statements. In addition it requires only little memory at runtime (approx. 250 KByte). SQLite is a software library that implements a self-contained, serverless, zero- configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world [3, 7]. SQLite s the data types TEXT (similar to String in Java), INTEGER (similar to long in Java) and REAL (similar to double in Java). All other types must be converted into one of these fields before saving them in the database. SQLite itself does not validate if the types written to the columns are actually of the defined type, e.g. writing an integer into a string column and vice versa. SQLite is available on every Android device. Using an SQLite database in Android does not require any database setup or istration. The SQL statements for creating and updating the database must only be defined and the database is automatically managed for s by the Android platform.
! |Page 17
2.6 USING THE SQLITE DATABASE Android provides full for SQLite databases. Any databases that is created will be accessible by name to any class in the application, but not outside the application. The recommended method to create a new SQLite database is to create a subclass of SQLiteOpenHelper and override the onCreate() method, in which and SQLite command is executed to create tables in the database. An example is shown in Figure 4.
You can then get an instance of the SQLiteOpenHelper implementation using the constructor that is being defined. To write to and read from the database, the getWritableDatabase() and getReadableDatabase() are called, respectively. Both returns an SQLiteDatabase object that represents the database and provides methods for SQLite operations. SQLite queries can be executed using the SQLiteDatabase query() methods, which accept various query parameters, such as the table to query, the projection, selection, columns, grouping, and others. For complex queries, such as those that require column aliases, the SQLiteQueryBuilder is used, which provides several convenient methods for building queries. ! |Page 18
Every SQLite query will return a Cursor that points to all the rows found by the query. The Cursor is always the mechanism with which can navigate results from a database query and read rows and columns [7].
2.7 OTHER DATABASES : Cellica Database for Android allows viewing and updating the database contents on an Android device. It allows to sync with Microsoft Access, Microsoft Excel, and any ODBC Compliant database like Oracle, SQL Server etc. The software package consists of two software: the Cellica Database Desktop (Server) that runs on Microsoft Windows, and Android device Cellica Database (Client) that run on the Android device. The Desktop side software is used to create the database profiles (make the list of database) for Android phone/ Tablet and data will be synchronizing with Android phone/Tablet depending on the sync settings on phone/Tablet [8]. Cellica Database on Android phone/Tablet features include synchronized data wirelessly with Android phone/Tablet, view and update data, apply SQL Select queries, filters, sort the fields and synchronize data accordingly, ed protection, ed forms, custom database creation, and so on. Memento is a personal database that allows Android s to store all personal data in one place. Entries can be synchronized with Google Docs. For example, Memento handles collections, purchases, inventory, recipes, and tasks. Main features include storing entries with custom fields, sorting, grouping and filtering entries by any fields, protection, synchronization with Google docs, sending entries via SMS, e- mail and other available devices, barcode scanning, backing up entries and restoring data, and so on.
! |Page 19
CHAPTER 3 ANALYSIS
! |Page 20
3.1 INTRODUCTION System analysis refers to analysing the projects hardware and software requirements. It is often done for diagnostic or troubleshooting purposes. Running a system analysis can also be helpful when determining if the project meets all the desired requirements.
3.2 EXISTING SYSTEM Presently we have to options available : 1. Generally all the communication details of the students are stored in a database and whenever they or their parents need to be ed the information needs to be searched in the database and retrieved. Then proper means of communication has to be adopted. 2. We have a phone directory but opening that and storing names and details of individual students is a long process. For each and every student their details needs to be stored and a separate of their parent also needs to be created.
LIMITATIONS OF EXIXTING SYSTEM Both the methods are time consuming and there is also a chance of loss of data.Also proper maintenance of the information is needed and proper storage and retrieval techniques needs to be applied in order to maintain the consistency of database.
3.3 PROPOSED SYSTEM The aim of our mini project is to develop a mobile application which contains the details of the students and also their parents in an embedded database. This
! |Page 21
would help the faculties to the student or their parents via a phone call , message or an e-mail as and when its required .
ADVANTAGES OF PROPOSED SYSTEM 1.There is no chance of loss of data 2.It doesn't require any maintenance to manage all the information 3.Very easy to use and communicate whenever required
3.4 HARDWARE AND SOFTWARE REQIREMENT SPECIFICA TION 3.4.1 HARDWARE REQIREMENTS : PROCESSOR : Core i3 and above RAM : 4GB RAM MONITOR : 15” COLOR HARD DISK : 80 GB
3.4.2 SOFTWARE REQUIREMENTS: Front End : Java , Xml Back End : SQLite Operating System : Windows Family, MAC OS, Linux etc.. IDE : Android Studio AVD: Android Emulator or Genymotion
! |Page 22
CHAPTER 4 DESIGN
! |Page 23
4.1 DESIGN DETAILS The Unified Modeling Language (UML) offers a way to visualize a system's architectural blueprints in a diagram including elements such as: • Individual components of the system • And how Any activities (jobs) • they can interact with other software components. • How the system will run • How entities interact with others (components and interfaces) • External Interface. Although originally intended solely for object-oriented design documentation, the Unified Modelling Language (UML) has been extended to cover a larger set of design documentation (as listed above), and been found useful in many contexts.
4.1.1 DATA FLOW DIAGRAM : A data flow diagram (DFD) is a graphical representation of the “flow” of data through an information system. It differs from the flowchart as it shows the data flow instead of the control flow of the program. A data flow diagram can also be used for the visualisation of data processing. The DFD is designed to show how a system is divided into smaller portions and to highlight the flow of data between those parts.
! |Page 24
FIGURE : DATA FLOW DIAGRAM
! |Page 25
USE CASE DIAGRAM A use case diagram at its simplest is a representation of a 's interaction with the system and depicting the specifications of use-case. A use case diagram can portray the different types of s of a system and the various ways that they interact with the system. A use case diagram can also be defined as s interaction the system that shows the relationship between the and the different use cases in which the is involved. A use case diagram can identify the different types of s of a system and the different use cases and will often be accompanied by other types of diagrams as well. IDENTIFYING ACTORS: Actor is a role of an object Actor:
IDENTIFYING USE CASES: Use-cases represents set of scenarios 1.Select 2.Students List 3.Search Student 4.Make Phone Call 5.Send Message 6.Send E-mail
! |Page 26
FIGURE: USECASE DIAGRAM
! |Page 27
CLASS DIAGRAM In software engineering, a class diagram in the Unified Modeling Language (UML) is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations (or methods), and the relationships among the classes.
IDENTIFYING CLASES : Class can be defined as a collection of objects that share common properties and relationships. Class1: Class2: Student List Class3: Information Class4: Communication FIGURE : CLASS DIAGRAM
! |Page 28
OBJECT DIAGRAM Object diagrams reflect class diagrams in of real time aspects.Addresses the data structures and provide snapshots of instances of elements internal to a class diagram.
IDENTIFYING OBJECTS: 1. 2. Student List 3. Information
FIGURE : OBJECT DIAGRAM
! |Page 29
COMPONENT DIAGRAM The component diagram is used to address implementation view of the system that is to be modelled.
IDENTIFYING OBJECTS : Components bind several classes, interfaces and collaborations by physical representation. 1. Intel XDK 2. Notepad ++ 3. Operating system
FIGURE : COMPONENT DIAGRAM
Note-
Intel
Operatingsystem
!
! |Page 30
DEPLOYMENT DIAGRAM Deployment diagrams reflect static deployment view of the system.The nodes which form the major entity of the deployment diagrams take in the components corresponding to the component diagrams before finalizing the static framework of the system.
IDENTIFYING NODES: 1. Processor 2. Android phone
FIGURE : DEPLOYMENT DIAGRAM
!
! |Page 31
CHAPTER 5 IMPLEMENTATION
! |Page 32
5.1 MODULES In this we have 4 modules: 1. GUI 2. Sending message to student or parent 3. Calling a parent or student message from database 4. Sending e-mails to the student
5.2 MODULE DESCRIPTION GUI It has got a good graphical interface. This GUI can be used to send message or e-mails and make phone calls from the application easily. SENDING MESSAGE TO STUDENT OR PARENT After searching for a particular student message can be easily sent to either student or parent via a normal message or other applications like WhatsApp , Hike etc. CALLING A PARENT OR STUDENT Calls can be made both to the student or their parent very easily with a feature also of internet calling. SENDING E-MAILS Mails can be sent easily with the of inbuilt mailing apps.
! |Page 33
5.3 TECHNOLOGIES USED JAVA Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers. While they are less common than standalone Java applications, Java applets run in secure, sandboxed environments to provide many features of native applications and can be embedded in HTML pages. Writing in the Java programming language is the primary way to produce code that will be deployed as byte code in a Java Virtual Machine (JVM); byte code compilers are also available for other languages, including Ada, JavaScript, Python, and Ruby. In addition, several languages have been designed to run natively on the JVM, including Scala, Clojure and Apache Groovy. Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective-C. Java eschews certain low-level constructs such as pointers and has a very simple memory model where every object is allocated on the heap and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the JVM. ANDROID STUDIO Android Studio is the official integrated development environment (IDE) for Android platform development.It was announced on May 16, 2013 at the Google I/O conference. Android Studio is freely available under the Apache License 2.0. Android Studio was in early access preview stage starting from version 0.1 in May 2013, then entered beta stage starting from version 0.8 which was released in June ! |Page 34
2014.The first stable build was released in December 2014, starting from version 1.0. Based on JetBrains' IntelliJ IDEA software, Android Studio is designed specifically for Android development. It is available for on Windows, Mac OS X and Linux,and replaced Eclipse Android Development Tools (ADT) as Google's primary IDE for native Android application development. SQLITE DATABASE SQLite is an in-process library that implements a self-contained, serverless, zeroconfiguration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects. SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file. The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures. These features make SQLite a popular choice as an Application File Format. Think of SQLite not as a replacement for Oracle but as a replacement for fopen(). SQLite is a compact library. With all features enabled, the library size can be less than 500KiB, depending on the target platform and compiler optimization settings. (64-bit code is larger. And some compiler optimizations such as aggressive function inlining and loop unrolling can cause the object code to be much larger.) If optional features are omitted, the size of the SQLite library can be reduced below 300KiB. SQLite can also be made to run in minimal stack space (4KiB) and very little heap (100KiB), making SQLite a popular database engine choice on memory constrained ! |Page 35
gadgets such as cellphones, PDAs, and MP3 players. There is a tradeoff between memory usage and speed. SQLite generally runs faster the more memory you give it. Nevertheless, performance is usually quite good even in low-memory environments.
5.4 SAMPLE CODE MAINACTIVITY.JAVA package com.saurabh.studentprofiles; import android.annotation.TargetApi; import android.app.ListActivity; import android.app.SearchManager; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android..v4.widget.SimpleCursorAdapter; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ListView; import android.widget.SearchView; import java.util.List; public class MainActivity extends ListActivity { public List<Student> students; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! |Page 36
setContentView(R.layout.activity_main); new LoadStudentsTask().execute(); } private class LoadStudentsTask extends AsyncTask<String, Void, Cursor> { @Override protected Cursor doInBackground(String... args) { Uri uri = StudentProvider.CONTENT_URI; String[] projection = { StudentDatabase.COLUMN_ID, StudentDatabase.COLUMN_FIRSTNAME, StudentDatabase.COLUMN_LASTNAME, StudentDatabase.COLUMN_ROLL, StudentDatabase.COLUMN_DEPARTMENT, StudentDatabase.COLUMN_FNAME, StudentDatabase.COLUMN_PARENT_PHONE, StudentDatabase.COLUMN_MOBILE_PHONE, StudentDatabase.COLUMN_EMAIL, StudentDatabase.COLUMN_PICTURE }; String selection = null; String[] selectionArgs = null; String sortOrder = StudentDatabase.COLUMN_ROLL + " COLLATE LOCALIZED ASC"; Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); return cursor; } @Override protected void onPostExecute(Cursor cursor) { String[] dataColumns = { StudentDatabase.COLUMN_FIRSTNAME, StudentDatabase.COLUMN_ROLL, StudentDatabase.COLUMN_DEPARTMENT, StudentDatabase.COLUMN_FNAME, StudentDatabase.COLUMN_PARENT_PHONE, StudentDatabase.COLUMN_MOBILE_PHONE, ! |Page 37
StudentDatabase.COLUMN_EMAIL, StudentDatabase.COLUMN_PICTURE }; int[] viewIDs = { R.id.list_item_name, R.id.list_item_title, R.id.list_item_department, R.id.list_item_city, R.id.list_item_office_phone, R.id.list_item_mobile_phone, R.id.list_item_email, R.id.list_item_picture }; SimpleCursorAdapter records = new SimpleCursorAdapter(getBaseContext(), R.layout.list_item, cursor, dataColumns, viewIDs, 0); setListAdapter(records); } } @Override protected void onListItemClick(ListView l, View view, int position, long id) { Uri details = Uri.withAppendedPath(StudentProvider.CONTENT_URI, "" + id); Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details); startActivity(detailsIntent); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); ! |Page 38
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_search: onSearchRequested(); return true; default: return false; } } } DETAILACTIVITY.JAVA package com.saurabh.studentprofiles; import java.io.IOException; import java.io.InputStream; import android.annotation.SuppressLint; import android.app.Activity; import android.content.ContentUris; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; ! |Page 39
import android.graphics.BitmapFactory; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.TextView; public class DetailActivity extends Activity implements OnClickListener { public TextView mName; public TextView rollno; public TextView mDepartment; public TextView fname; private TextView mParentPhone; private TextView mMobilePhone; private TextView mSms; private TextView mEmail; private TextView psms; private ImageView mPicture; private int mID; public Uri uri; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ! |Page 40
setContentView(R.layout.activity_detail); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } Intent intent = getIntent(); Uri launchData = intent.getData(); mID = Integer.parseInt(launchData.getLastPathSegment()); uri = ContentUris.withAppendedId(StudentProvider.CONTENT_URI, mID); mName = (TextView) findViewById(R.id.activity_detail_name); rollno = (TextView) findViewById(R.id.activity_detail_title); mDepartment = (TextView) findViewById(R.id.activity_detail_department); fname = (TextView) findViewById(R.id.activity_detail_city); mParentPhone = (TextView) findViewById(R.id.activity_detail_office_phone); mMobilePhone = (TextView) findViewById(R.id.activity_detail_mobile_phone); mSms = (TextView) findViewById(R.id.activity_detail_sms); psms=(TextView)findViewById(R.id.activity_detail_parent_sms); mEmail = (TextView) findViewById(R.id.activity_detail_email); mPicture = (ImageView) findViewById(R.id.activity_detail_picture); findViewById(R.id.activity_detail_call_office_button).setOnClickListener(this); findViewById(R.id.activity_detail_office_phone).setOnClickListener(this); findViewById(R.id.activity_detail_call_mobile_button).setOnClickListener(this); findViewById(R.id.activity_detail_mobile_phone).setOnClickListener(this); findViewById(R.id.activity_detail_send_sms_button).setOnClickListener(this); findViewById(R.id.activity_detail_sms).setOnClickListener(this); findViewById(R.id.activity_detail_send_parent_sms_button).setOnClickListener(this );findViewById(R.id.activity_detail_parent_sms).setOnClickListener(this); findViewById(R.id.activity_detail_send_email_button).setOnClickListener(this); findViewById(R.id.activity_detail_email).setOnClickListener(this); PhoneCallListener phoneListener = new PhoneCallListener(); ! |Page 41
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE); new LoadEmployeesTask().execute(); } private class LoadEmployeesTask extends AsyncTask<String, Void, Cursor> { @Override protected Cursor doInBackground(String... args) { String[] projection = { StudentDatabase.COLUMN_ID, StudentDatabase.COLUMN_FIRSTNAME,StudentDatabase.COLUMN_LASTNAME, StudentDatabase.COLUMN_ROLL,StudentDatabase.COLUMN_DEPARTMENT, StudentDatabase.COLUMN_FNAME,StudentDatabase.COLUMN_PARENT_PHONE, StudentDatabase.COLUMN_MOBILE_PHONE,StudentDatabase.COLUMN_EMAIL, StudentDatabase.COLUMN_PICTURE }; String selection = null; String[] selectionArgs = null; String sortOrder = null; Cursor cursor = getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); return cursor; } @Override protected void onPostExecute(Cursor cursor) { if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); mName.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_FIRSTNAME))); mName.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_LASTNAME))); ! |Page 42
rollno.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_ROLL))); mDepartment.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_DEPARTMENT))); fname.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_FNAME))); mParentPhone.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_PARENT_PHONE))); mMobilePhone.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_MOBILE_PHONE))); mSms.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_MOBILE_PHONE))); psms.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_PARENT_PHONE))); mEmail.setText(cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_EMAIL))); InputStream is; try { is = getAssets().open("pics/" + cursor.getString(cursor.getColumnIndex(StudentDatabase.COLUMN_PICTURE))); Bitmap bit = BitmapFactory.decodeStream(is); mPicture.setImageBitmap(bit); } catch (IOException e) { e.printStackTrace(); } } } } @Override ! |Page 43
public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { Intent parentActivityIntent = new Intent(this, MainActivity.class); parentActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(parentActivityIntent); finish(); return true; } return super.onOptionsItemSelected(item); } public void onClick(View view) { switch (view.getId()) { case R.id.activity_detail_call_office_button: case R.id.activity_detail_office_phone: case R.id.textView5:
// clicking on textView will
Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + mParentPhone.getText().toString())); startActivity(Intent.createChooser(callIntent, "Choose an Call client :")); break; case R.id.activity_detail_call_mobile_button: case R.id.activity_detail_mobile_phone: case R.id.textView7: Intent callIntent2 = new Intent(Intent.ACTION_CALL); ! |Page 44
callIntent2.setData(Uri.parse("tel:" + mMobilePhone.getText().toString())); startActivity(Intent.createChooser(callIntent2, "Choose an Call client :")); break; case R.id.activity_detail_send_sms_button: case R.id.activity_detail_sms: case R.id.textView9: Intent smsIntent = new Intent(Intent.ACTION_SENDTO); smsIntent.setData(Uri.parse("smsto:" + mMobilePhone.getText().toString())); startActivity(Intent.createChooser(smsIntent, "Choose an Sms client :")); break; case R.id.activity_detail_send_parent_sms_button: case R.id.activity_detail_parent_sms: case R.id.textView13: Intent psmsIntent = new Intent(Intent.ACTION_SENDTO); psmsIntent.setData(Uri.parse("smsto:" + mMobilePhone.getText().toString())); startActivity(Intent.createChooser(psmsIntent, "Choose an Sms client :”)); break; case R.id.activity_detail_send_email_button: case R.id.activity_detail_email: case R.id.textView11: String to = mEmail.getText().toString(); String subject = "textSubject"; String message = "textMessage"; Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_EMAIL, new String[] { to }); email.putExtra(Intent.EXTRA_SUBJECT, subject); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); ! |Page 45
startActivity(Intent.createChooser(email, "Choose an Email client :")); break; } } private class PhoneCallListener extends PhoneStateListener { private boolean isPhoneCalling = false; String LOG_TAG = “LANGDON"; @Override public void onCallStateChanged(int state, String incomingNumber) { if (TelephonyManager.CALL_STATE_RINGING == state) { Log.i(LOG_TAG, "RINGING, number: " + incomingNumber); } if (TelephonyManager.CALL_STATE_OFFHOOK == state) { Log.i(LOG_TAG, "OFFHOOK"); isPhoneCalling = true; } if (TelephonyManager.CALL_STATE_IDLE == state) { Log.i(LOG_TAG, "IDLE"); if (isPhoneCalling) { Log.i(LOG_TAG, "restart app"); Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage( getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); isPhoneCalling = false; } } } } } ! |Page 46
STUDENTXMLPARSER.JAVA package com.saurabh.studentprofiles; import android.content.Context; import android.view.MenuItem; import android.widget.Button; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; public class StudentXmlParser { static final String STUDENTS = "students"; static final String STUDENT = "student"; static final String ID = "id"; static final String FIRSTNAME = "firstName"; static final String LASTNAME = "lastName"; static final String ROLLNO = "rollno"; static final String DEPARTMENT = "department"; static final String FNAME = "fname"; static final String PARENTPHONE = "parentPhone"; static final String MOBILEPHONE = "mobilePhone"; static final String EMAIL = "email"; static final String PICTURE = "picture"; ArrayList<Student> studentList = null; private Student currentStudent = null; private boolean done = false; private String currentTag = null; public ArrayList<Student> parse(Context context) { XmlPullParser parser = context.getResources().getXml(R.xml.student_list); ! |Page 47
try { int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT && !done) { switch (eventType) { case XmlPullParser.START_DOCUMENT: studentList = new ArrayList<Student>(); break; case XmlPullParser.START_TAG: currentTag = parser.getName(); if (currentTag.equalsIgnoreCase(STUDENT)) { currentStudent = new Student(); } else if (currentStudent != null) { if (currentTag.equalsIgnoreCase(ID)) { currentStudent.setId(Integer.parseInt(parser.nextText())); } else if (currentTag.equalsIgnoreCase(FIRSTNAME)) { currentStudent.setFirstName(parser.nextText()); } else if (currentTag.equalsIgnoreCase(LASTNAME)) { currentStudent.setLastName(parser.nextText()); else if (currentTag.equalsIgnoreCase(ROLLNO)) { currentStudent.setTitle(parser.nextText()); } else if (currentTag.equalsIgnoreCase(DPARTMENT)) { currentStudent.setDepartment(parser.nextText()); } else if (currentTag.equalsIgnoreCase(FNAME)) { currentStudent.setCity(parser.nextText()); } else if (currentTag.equalsIgnoreCase(PARENTPHONE)) { currentStudent.setOfficePhone(parser.nextText()); } else if (currentTag.equalsIgnoreCase(MOBILEPHONE)) { currentStudent.setMobilePhone(parser.nextText()); } else if (currentTag.equalsIgnoreCase(EMAIL)) { ! |Page 48
}
currentStudent.setEmail(parser.nextText()); } else if (currentTag.equalsIgnoreCase(PICTURE)) { currentStudent.setPicture(parser.nextText()); } } break;case XmlPullParser.END_TAG: currentTag = parser.getName(); if (currentTag.equalsIgnoreCase(STUDENT) && currentStudent != null) { studentList.add(currentStudent); } else if (currentTag.equalsIgnoreCase(STUDENTS)) { done = true; } break; }
eventType = parser.next();
} } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return studentList; } }
! |Page 49
STUDENTDATABASE.JAVA package com.saurabh.studentprofiles; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import java.util.ArrayList; public class StudentDatabase extends SQLiteOpenHelper { private Context context; ArrayList<Student> studentList = new ArrayList<Student>(); private static final int DATABASE_VERSION = 1; private static final String DATABASE_NAME = "student_directory"; public static final String TABLE_STUDENTS = "students"; public static final String COLUMN_ID = "_id"; public static final String COLUMN_FIRSTNAME = "first_name"; public static final String COLUMN_LASTNAME = "last_name"; public static final String COLUMN_ROLL = "rollno"; public static final String COLUMN_DEPARTMENT = "department"; public static final String COLUMN_FNAME = "fathername"; public static final String COLUMN_PARENT_PHONE = "parent_phone"; public static final String COLUMN_MOBILE_PHONE = "mobile_phone"; public static final String COLUMN_EMAIL = "email"; public static final String COLUMN_PICTURE = "picture"; private static final String CREATE_TABLE_STUDENTS = "CREATE TABLE " + TABLE_STUDENTS + " (" + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ COLUMN_FIRSTNAME + " TEXT NOT NULL, " + COLUMN_LASTNAME + " TEXT NOT NULL, " + COLUMN_ROLL + " TEXT NOT NULL, "
! |Page 50
+ COLUMN_DEPARTMENT + " TEXT NOT NULL, " + COLUMN_FNAME + " TEXT NOT NULL, " + COLUMN_PARENT_PHONE + " TEXT NOT NULL, " + COLUMN_MOBILE_PHONE + " TEXT NOT NULL, " + COLUMN_EMAIL + " TEXT NOT NULL, " + COLUMN_PICTURE + " TEXT NOT NULL);"; public StudentDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); this.context = context; // DO I NEED THIS??? } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_STUDENTS); seedData(db); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_STUDENTS); onCreate(db); } private void seedData(SQLiteDatabase db) { StudentXmlParser parser = new StudentXmlParser(); studentList = parser.parse(context); for (Student student : studentList) { db.execSQL("INSERT INTO students (" + COLUMN_FIRSTNAME + ", " + COLUMN_LASTNAME + ", " + COLUMN_ROLL + ", " + COLUMN_DEPARTMENT + ", " + COLUMN_FNAME + ", " ! |Page 51
+ COLUMN_PARENT_PHONE + ", " + COLUMN_MOBILE_PHONE + ", " + COLUMN_EMAIL + ", " + COLUMN_PICTURE + ")" + " values (\"" + String.valueOf(student._firstName) + "\", \"" + String.valueOf(student._lastName) + "\", \"" + String.valueOf(student._rollno) + "\", \"" + String.valueOf(student._department) + "\", \"" + String.valueOf(student._fname) + "\", \"" + String.valueOf(student._parentPhone) + "\", \"" + String.valueOf(student._mobilePhone) + "\", \"" + String.valueOf(student._email) + "\", \"" + String.valueOf(student._picture) + "\");"); } } }
! |Page 52
StudentProvider.java package com.saurabh.studentprofiles; import android.app.SearchManager; import android.content.ContentProvider; import android.content.ContentResolver; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import java.util.HashMap; public class StudentProvider extends ContentProvider { private StudentDatabase mStudentDatabase; private final UriMatcher mUriMatcher; private static final String AUTHORITY = "com.saurabh.studentprofiles.StudentProvider"; public static final String BASE_DATA_NAME = "students"; public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd.saurabh.search." + BASE_DATA_NAME; public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd.saurabh.search." + BASE_DATA_NAME; public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_DATA_NAME); public static final Uri SEARCH_SUGGEST_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_DATA_NAME + "/" + SearchManager.SUGGEST_URI_PATH_QUERY); private static final int STUDENTS = 1; ! |Page 53
private static final int STUDENTS_ID = 2; private static final int SEARCH_SUGGEST = 3; private static final HashMap<String, String> SEARCH_SUGGEST_PROJECTION_MAP; static { SEARCH_SUGGEST_PROJECTION_MAP = new HashMap<String, String>(); SEARCH_SUGGEST_PROJECTION_MAP.put(StudentDatabase.COLUMN_ID, StudentDatabase.COLUMN_ID); SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUGGEST_COLUMN_TEXT_1, StudentDatabase.COLUMN_FIRSTNAME + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_1); SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUGGEST_COLUMN_TEXT_2, StudentDatabase.COLUMN_LASTNAME + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_2); SEARCH_SUGGEST_PROJECTION_MAP.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, StudentDatabase.COLUMN_ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID); } public StudentProvider() { mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(AUTHORITY, StudentDatabase.TABLE_STUDENTS, STUDENTS); mUriMatcher.addURI(AUTHORITY, StudentDatabase.TABLE_STUDENTS + "/#", STUDENTS_ID); mUriMatcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); mUriMatcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); } ! |Page 54
@Override public boolean onCreate() { mStudentDatabase = new StudentDatabase(getContext()); return true; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); queryBuilder.setTables(StudentDatabase.TABLE_STUDENTS); switch (mUriMatcher.match(uri)) { case SEARCH_SUGGEST: selectionArgs = new String[] { "%" + selectionArgs[0] + "%", "%" + selectionArgs[0] + "%" }; queryBuilder.setProjectionMap(SEARCH_SUGGEST_PROJECTION_MAP); break; case STUDENTS: break; case STUDENTS_ID: queryBuilder.appendWhere(StudentDatabase.COLUMN_ID + "=" + uri.getLastPathSegment()); break; default: throw new IllegalArgumentException("Unknown URI"); } Cursor cursor = queryBuilder.query(mStudentDatabase.getReadableDatabase(), projection, selection, selectionArgs, null,null, sortOrder); ! |Page 55
cursor.setNotificationUri(getContext().getContentResolver(), uri); return cursor; } @Override public String getType(Uri uri) { switch (mUriMatcher.match(uri)) { case STUDENTS: return CONTENT_TYPE; case STUDENTS_ID: return CONTENT_ITEM_TYPE; case SEARCH_SUGGEST: return null; default: throw new IllegalArgumentException("Unknown URI " + uri); } } @Override public Uri insert(Uri uri, ContentValues values) { return null; } @Override public int delete(Uri uri, String selection, String[] selectionArgs) { return 0; } @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { return 0; }} ! |Page 56
STUDENT.JAVA package com.saurabh.studentprofiles; public class Student { Integer _stuID; String _firstName; String _lastName; String _rollno; String _department; String _fname; String _parentPhone; String _mobilePhone; String _email; String _picture; public Student(Integer empID, String firstName, String lastName, String title, String department, String city, String officePhone, String mobilePhone, String email, String picture) { this._stuID = empID; this._firstName = firstName; this._lastName = lastName; this._rollno = title; this._department = department; this._fname = city; this._parentPhone = officePhone; this._mobilePhone = mobilePhone; this._email = email; this._picture = picture; } public void setId(Integer empID) { this._stuID = empID; } ! |Page 57
public void setFirstName(String firstName) { this._firstName = firstName; } public void setLastName(String lastName) { this._lastName = lastName; } public void setTitle(String title) { this._rollno = title; } public void setDepartment(String department) { this._department = department; } public void setCity(String city) { this._fname = city; } public void setOfficePhone(String officePhone) { this._parentPhone = officePhone; } public void setMobilePhone(String mobilePhone) { this._mobilePhone = mobilePhone; } public void setEmail(String email) { this._email = email; } public void setPicture(String picture) { this._picture = picture; } public Integer getId() { return this._stuID; } ! |Page 58
public String getFirstName() { return this._firstName; } public String getLastName() { return this._lastName; } public String getTitle() { return this._rollno; } public String getDepartment() { return this._department; } public String getCity() { return this._fname; } public String getOfficePhone() { return this._parentPhone; } public String getMobilePhone() { return this._mobilePhone; } public String getPicture() { return this._picture; } @Override public String toString() { return _firstName + " " + _lastName + "\n" + _rollno; } } ! |Page 59
SEARCHABLEACTIVITY.JAVA package com.saurabh.studentprofiles; import android.annotation.TargetApi; import android.app.ListActivity; import android.app.SearchManager; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.SimpleCursorAdapter; public class SearchableActivity extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); checkIntent(intent); } @Override protected void onNewIntent(Intent newIntent) { setIntent(newIntent); checkIntent(newIntent); } private void checkIntent(Intent intent) { ! |Page 60
String query = ""; String intentAction = intent.getAction(); if (Intent.ACTION_SEARCH.equals(intentAction)) { query = intent.getStringExtra(SearchManager.QUERY); } else if (Intent.ACTION_VIEW.equals(intentAction)) { Uri details = intent.getData(); Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details); startActivity(detailsIntent); } fillList(query); } private void fillList(String query) { String wildcardQuery = "%" + query + "%"; Cursor cursor = getContentResolver().query( StudentProvider.CONTENT_URI, null, StudentDatabase.COLUMN_FIRSTNAME + " LIKE ? OR " + StudentDatabase.COLUMN_ROLL + " LIKE ?", new String[] { wildcardQuery, wildcardQuery },null); ListAdapter adapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_2, cursor, new String[] { StudentDatabase.COLUMN_FIRSTNAME, StudentDatabase.COLUMN_ROLL }, new int[] { android.R.id.text1, android.R.id.text2 }, 0); setListAdapter(adapter); } @Override ! |Page 61
protected void onListItemClick(ListView l, View view, int position, long id) { Uri details = Uri.withAppendedPath(StudentProvider.CONTENT_URI, "" + id); Intent detailsIntent = new Intent(Intent.ACTION_VIEW, details); startActivity(detailsIntent); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { Intent parentActivityIntent = new Intent(this, MainActivity.class); parentActivityIntent.addFlags(Intent.FLAG_ACTIVITY_ CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(parentActivityIntent); finish(); return true; } return super.onOptionsItemSelected(item); }}
! |Page 62
5.5 SOME PICTURES OF PROPOSED SYSTEM
SRC 1: STUDENTS DETAILS IN LIST VIEW
SRC 2 : SEARCHING A PARTICULAR STUDENT ! |Page 63
SRC 3: COMMUNICATION DETAILS
SRC 4 : MESSAGING OPTIONS
! |Page 64
SRC 5 : E-MAIL OPTIONS
! |Page 65
CHAPTER 6 TESTING
! |Page 66
6.1 INTRODUCTION The development of software systems involves of a series of production activities where opportunities for injection of human fallibilities are enormous. Errors may begin to occur at the very inception of the process where the objectives may be erroneously or imperfectly specified, as well as in later design and development stages. Because of human inability to perform and communicate with perfection, software development is accompanied by a quality assurance activity. In general, testing is finding out how well something works. In of human beings, testing tells what level of knowledge or skill has been acquired. In computer hardware and software development, testing is used at key checkpoints in the overall process to determine whether objectives are being met. For example, in software development, product objectives are sometimes tested by product representatives. When the design is complete, coding follows and the finished code is then tested at the unit or module level by each programmer; at the component level by the group of programmers involved; and at the system level when all components are combined together. At early or late stages, a product or service may also be tested for usability. 6.2 TESTING TOOL UNIT TESTING : Unit testing is a software development process in which the smallest testable parts of anapplication, called units, are individually and independently scrutinized for proper operation. Unit testing is often automated but it can also be done manually. This testing mode is a component of Extreme Programming (XP), a pragmatic method of software development that takes a meticulous approach to building a product by means of continual testing and revision.
! |Page 67
Unit testing involves only those characteristics that are vital to the performance of the unit under test. This encourages developers to modify the source code without immediate concerns about how such changes might affect the functioning of other units or the program as a whole. 6.3 TEST CASES The development of software systems involves of a series of production activities where opportunities for injection of human fallibilities are enormous. Errors may begin to occur at the very inception of the process where the objectives may be erroneously or imperfectly specified, as well as in later design and development stages.
Test Case 1 Test case 1: Home page
Priority (H, L): High
Test Objective: To check if home page is working Test Description: All the students name are displayed or not Requirements Verified: Yes Test Environment: Application must be deployed in android mobile phone or emulator. Test Setup/Pre-Conditions: Actions The tries to access home page : Yes
Conditions : Yes
Problems / Issues: NIL Notes: Successfully Executed
! |Page 68
Expected Results Home page working Fail: No
Test Case 2 Test case 2:Communication Details on click
Priority (H, L): High
Test Objective: Accessing details from database Test Description: Request to the database Requirements Verified: Yes Test Environment: Application must be deployed in android mobile phone or emulator. Test Setup/Pre-Conditions: Actions
Expected Results
click on picture
Picture maximizes
: Yes
Conditions : Yes
Fail: No
Problems / Issues: NIL Notes: Successfully Executed
Test Case 3 Test case 3: Application functions working
Priority (H, L): High
Test Objective: To check functions of application Test Description: All the functions working or no Requirements Verified: Yes Test Environment: Application must be deployed in android mobile phone or emulator. Test Setup/Pre-Conditions: Actions Pronunciation check : Yes
Functions working Conditions : Yes
Problems / Issues: NIL Notes: Successfully Executed
! |Page 69
Expected Results
Fail: No
7.CONCLUSION This application is built in Android Studio using its SDK tools .This application can be used by the staff to communicate with the students and their parents as and when its required without wasting any time. All the details related to a particular student are displayed and directly phone calls,messages or mails can be made from this application to any particular individual.Thus the communication between the faculty , students and their parents is enhanced.
8. FUTURE SCOPE This project can be modified in future in order to maintain all the student related information of the entire college in a single application.Several other changes like internet messaging and internet calling are also possible to be added.It has all the features to become a substitute for the most commonly used inbuilt phone directory.Ease of use , no chance of loss of data and less maintenance cost makes it a highly desired application for the s.Apart from the application part android widget for the application can also be created which would provide a much faster access to a particular individuals information instead of searching for a particular person.
! |Page 70
! |Page 71