Part A: 2020 March
Part A: 2020 March
Module 4 : Android
2020 March
2021 April
● moveToFirst() method is used to move the cursor to the first row of the result set,
and returns a boolean value indicating whether the move was successful or not. This
method is commonly used to retrieve the first row of data from the cursor.
● moveToLast() method is used to move the cursor to the last row of the result set,
and returns a boolean value indicating whether the move was successful or not. This
method is commonly used to retrieve the last row of data from the cursor.
This code snippet moves the cursor to position 2 (i.e., the third record) and checks if the
move was successful before processing the data.
2022 April
This method is used to execute a SELECT query on the specified table in the SQLite
database. It returns a Cursor object that contains the result set of the query.
Part B
Module 4 : Android
2020 March
Developers can use these packages to build Wi-Fi enabled apps on Android, whether they
are simple or complex, as they offer a range of tools and necessary functionality for
connecting to Wi-Fi networks or utilizing advanced Wi-Fi technologies like Wi-Fi Direct or Wi-
Fi Aware.
20. Write a java and xml code to save the details of student to
sqlite table student(regno, name, address).
Java code:
public class AddStudentActivity extends AppCompatActivity {
EditText regnoText, nameText, addressText;
Button addButton;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_student_layout);
regnoText = findViewById(R.id.regno);
nameText = findViewById(R.id.name);
addressText = findViewById(R.id.address);
addButton = findViewById(R.id.addBtn);
regnoText.setText("");
nameText.setText("");
addressText.setText("");
});
}
}
XML Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<EditText
android:id="@+id/regno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Registration Number"/>
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"/>
<EditText
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Address"/>
<Button
android:id="@+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
</LinearLayout>
2021 April
Example:
// Get instance of SMS Manager
SmsManager smsManager = SmsManager.getDefault();
// Send SMS
smsManager.sendTextMessage(phoneNumber, null, message, null, null);
Here, we first obtain the instance of the SMS Manager using its getDefault() method.
Then, we define the recipient's phone number and message text. Finally, we call the
sendTextMessage() method, passing in the recipient's phone number, message text, and
other optional parameters.
Note: To send SMS, the sender needs to add the SEND_SMS permission to sender’s
AndroidManifest.xml file.
2022 April
The BroadcastReceiver allows the application to register for specific intent filters and receive
relevant broadcasts. When the Wi-Fi scan results are ready, the system broadcasts the
intent, which triggers the onReceive() method of the registered BroadcastReceiver. The
application can then extract the relevant information from the intent and perform any
necessary actions, such as displaying the available Wi-Fi access points in a list or map view.
20. Write a java and xml code to delete the details of students
from sqlite table student(regno, name, address) whose regno is
given.
First, create a layout file (delete_student_layout.xml) to input the registration number:
<EditText
android:id="@+id/regno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Registration Number"
/>
<Button
android:id="@+id/deleteBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Delete"
/>
Next, create a Java activity class (DeleteStudentActivity.java) to handle the deletion process:
public class DeleteStudentActivity extends AppCompatActivity {
EditText regnoText;
Button deleteButton;
SQLiteDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.delete_student_layout);
regnoText = findViewById(R.id.regno);
deleteButton = findViewById(R.id.deleteBtn);
deleteButton.setOnClickListener(v -> {
String regno = regnoText.getText().toString();
db.execSQL("DELETE FROM student WHERE regno = ?", new
String[]{regno});
Toast.makeText(this, "Student details deleted",
Toast.LENGTH_SHORT).show();
});
}
}
In the above code, we first initialize the views and get the database instance. Then we set a
click listener for the delete button, where we retrieve the registration number entered by the
user, execute the delete query, and display a toast message to confirm the deletion.
Part C
Module 4 : Android
2020 March
(No questions asked)
2021 April
(No questions asked)
2022 April
(No questions asked)