I’m developing an Android application in Android Studio and I’m in need of assistance with implementing several fundamental functionalities. Specifically, I require guidance on:
Using Intents for navigation between activities.
Displaying messages to the user using AlertDialog.
Sending notifications using NotificationManager.
Implementing MediaPlayer for audio playback.
Creating and managing a SQLite database, including table creation, inserting values, and fetching data based on conditions, using a DatabaseHelper class.
I’ve explored documentation and tutorials for each of these topics, but I’m struggling to integrate them effectively into my project.
Could someone please provide comprehensive examples or code snippets demonstrating the proper implementation of these functionalities in Android Studio, either in Java or Kotlin? Additionally, any insights into best practices or common pitfalls to avoid would be greatly appreciated.
I’ve explored documentation and tutorials for each of these topics, but I’m struggling to integrate them effectively into my project.
4
Answers
Example of a database helper program --
package com.example.l7q1;
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper {
}
Popup Menu example --
Basic layout for first page with spinner example --
main activity.java --
import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.PopupMenu; import android.widget.Spinner; import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList; import java.util.List;
public class MainActivity extends AppCompatActivity {
}
Example of another db oriented student details app —
Mainactivity.java–
Databasehelper.java —
Activity_main.xml —
.
Media player
Main Activity.java
activity_main.xml
activity_player.xml
I’d like to help, I recently made a Database related apps : You can go through the code and understand pretty clearly:
For studying Database in SQLite refer to the DatabaseHelper.java —
This is an example of airline ticket reservation system
BookingsActivity.java::
MainActivity.java::
DatabaseHelper.java:::
activity_bookings.xml::
activity_main.xml::
Also Don’t forget to use activity tag for Intent in the AndroidManifest.xml
It should look something like this::
If you need specifics feel free to ask, this is a very simple program which can help you learn the basics of DatabaseHelper.
Have to code dump here as Android studio is notorious for the app crashing if there is even a small error and gradle issues can be overwhelming.