Lecture 8 - SQLite (Part 2 Out of 2)
Lecture 8 - SQLite (Part 2 Out of 2)
</LinearLayout>
Navigate to the app > java > your app’s package name > Right-click on it
> New > Java class and name it as DBHandler and add the below code to
it. Comments are added inside the code to understand the code in more
detail.
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
Go to the MainActivity.java file and refer to the following code. Below is the
code for the MainActivity.java file. Comments are added inside the code to
understand the code in more detail.
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// below line is to add on click listener for our add course button.
addCourseBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {