Professional Documents
Culture Documents
UNIT-5
(Activities & Multimedia with Database )
M.A. Zahed Javeed
Lect. In computer
Government Polytechnic Jintur
Objectives
• After learning this unit the students can able to:
Apply Intent & services in android application
Use fragment to generate given multiple activities
Develop program to play multimedia
Write query to perform given database management operations.
Activity Lifecycle
• An activity represents a single screen with a user interface just like
window or frame of Java.Android activity is the subclass of
ContextThemeWrapper class.
• Android system initiates its program with in an Activity starting with a call
on onCreate() callback method. There is a sequence of callback methods
that start up an activity and a sequence of callback methods that tear
down an activity as shown in
Method Description
onCreate() called when the activity is first created.
onStart() when the activity becomes visible to the user.
onResume() when the user starts interacting with the
application.
onPause() when the current activity is being paused and the
previous activity is being resumed.
db.insert(PRODUCTS,null,values)
inserData("Jam","Fruit_jam",300.10,db);
inserData("Bread","BrownBread",30.10,db);
inserData("BrownBread","Bread",315.10,db);
inserData("Toast","RoastedToast",20.10,db);
CURSOR
• SELECT NAME, PRICE FORM
PRODUCTS
Cursor cursor= database.rawQuery
NAME PRICE ("SELECT NAME, PRICE FROM PRODUCTS",new
String[]{});
Jam 300.50
if(cursor!=null)
Bread 25.00 {
Corn Flake 380.00 cursor.moveToFirst();
}
StringBuilder stringBuilder=new StringBuilder();
• This interface provides do{
random read-write access to String name=cursor.getString(0);
double price=cursor.getDouble(1);
the result set returned by a stringBuilder.append("NAME-" + name+ "PRICE-"+
database query. price );
}while(cursor.moveToNext());
Update Records
• If we want to update the records
ID NAME DESCRIPTION PRICE
1 Jam Fruit Jam 300.50