Академический Документы
Профессиональный Документы
Культура Документы
10 marks
2. A. Explain Activity life cycle in android? 7 marks
B. What is An Intent? Define Types of intents? 3 marks
3. Explain the following?
a. Dalvik virtual Machine.4M
DVM
The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile
devices. It optimizes the virtual machine for memory, battery life and performance.
The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files are converted into one dex file.(1 mark)
2marks
The javac tool compiles the java source file into the class file.
The dx tool takes all the class files of your application and generates a single.dex file. It
is a platform-specific tool.
The Android Assets Packaging Tool (aapt) handles the packaging process.
Dalvik virtual machine uses register based architecture. With this architecture dalvik
virtual machine has few advantages over JAVA virtual machine such as:
1. Dalvik uses its own 16 bit instruction set than java 8 bit stack instructions, which reduce
the dalvik instruction count and raised its interpreter speed.
2. Dalvik use less space, which means an uncompressed. dex file is smaller in size (few
bytes) than compressed java archive file(.jar file). (1mark)
b. DDMS.2M
DDMS
The Dalvik Debug Monitor Service (DDMS) is a debugging tool used in the Android
platform. The Dalvik Debug Monitor Service is downloaded as part of the Android SDK.
1. port forwarding,
The Dalvik Debug Monitor Service allows developers to spot bugs in applications
For example, by using the DDMS’ LogCat feature, developers can view log messages
regarding the state of the application and the device. LogCat can pinpoint the exact
Another DDMS feature, known as the Emulator Control, allows developers to simulate
phone states and activities. For example, it can simulate different types of networks
such as GPRS, EDGE, and UTMS, which can have different network characteristics
with a device. The adb command facilitates a variety of device actions, such as installing
and debugging apps, and it provides access to a Unix shell that you can use to run a
components:
A client, which sends commands. The client runs on your development machine. You
A server, which manages communication between the client and the daemon. The
Android Option Menus are the primary menus of android. They can be used for settings,
Here, we are inflating the menu by calling the inflate() method of MenuInflater class.
menu_main.xml
<menu xmlns:androclass="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/item1"
android:title="Item 1"/>
<item android:id="@+id/item2"
android:title="Item 2"/>
<item android:id="@+id/item3"
android:title="Item 3"/>
</menu>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);//Menu Resource, Menu
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item1:
Toast.makeText(getApplicationContext(),"Item 1 Selected",Toast.LENGTH_LON
G).show();
return true;
case R.id.item2:
Toast.makeText(getApplicationContext(),"Item 2 Selected",Toast.LENGTH_LO
NG).show();
return true;
case R.id.item3:
Toast.makeText(getApplicationContext(),"Item 3 Selected",Toast.LENGTH_LO
NG).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
8. What is SQLite database? Write code for adding, updating and removing
data from SQLite database.
Ans:
SQLite is a well-regarded relational database management system (RDBMS).
It is:
1. Open-source
2. Standards-compliant
3. Lightweight
4. Single-tier
smartphones. (2 marks)
Inserting Rows To create a new row, construct a Content Values object and use
its put methods to add name/value pairs representing each column name and its
associated value. Insert the new row by passing the Content Values into the
insert method called on the target database — along with the table name — as
shown in
newValues.put(KEY_GOLD_HOARD_NAME_COLUMN, hoardName);
newValues.put(KEY_GOLD_HOARDED_COLUMN, hoardValue);
newValues.put(KEY_GOLD_HOARD_ACCESSIBLE_COLUMN, hoardAccessible);
SQLiteDatabase db = hoardDBOpenHelper.getWritableDatabase();
The second parameter used in the insert method known as the null column hack.
Content Values object, you must also pass in the name of a column whose value
When inserting a new row into an SQLite database, you must always explicitly
specify at least one column and a corresponding value, the latter of which can be
null. If you set the null column hack parameter to null, when inserting an empty
Content Values object SQLite will throw an exception. It’s generally good practice
to ensure that your code doesn’t attempt to insert empty Content Values into an
SQLite database.
Updating Rows Updating rows is also done with Content Values. Create a new
ContentValues object, using the put methods to assign new values to each
column you want to update. Call the update method on the database, passing in
the table name, the updated Content Values object, and a where clause that
updatedValues.put(KEY_GOLD_HOARDED_COLUMN, newHoardValue);
// Update the row with the specified index with the new values.
SQLiteDatabase db = hoardDBOpenHelper.getWritableDatabase();
Deleting Rows To delete a row, simply call the delete method on a database,
specifying the table name and a where clause that returns the rows you want to
delete,
null;