• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Java error no default constructor available in android database sqlite SQLHelper

Hjnash

Lurker
Yes I am new to Java and Android studio I am using a book "Android Studio Development Essentails"
I am in the section working with SQLite. I typed in the code example and there is an error with a
public class the error is " There is no default constructor available in android.database.sqlite.SQLiteOpenHelper".
Errors are expected when coding, I am also wanting to learn how to best debug errors,
this error is just over my head. I could use a fix for this.

**Copy of the java code is here**

package com.example.harry.devogellaandroidsqlitefirst;

/**
* Created by Harry on 3/18/2015.
*/

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;



public class MyDBHandler extends
SQLiteOpenHelper {

@override
public void onCreate(SQLiteDatabase db) {
}

@override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion) {
}
}

**end of the code section**

Screen shot of the studio showing error.

Java class error 1.jpg
 
You need to define a constructor for your class:

public MyDBHandler(Context context){
super(context,"database.db",null,1);
}

Thank you for your answer, I need to ask if this entry goes in the same .java file I
am seeing the error in, and if database.db is a file name in my project; perhaps the
file name I am editing above?
 
Back
Top Bottom