“There is no default constructor available in android.database.sqlite.SQLitepenhelper” in Android Studio

前端 未结 2 826
长发绾君心
长发绾君心 2021-01-17 16:19

Trying to extend class with SQLiteOpenHelper, but this error shows up : \"There is no default constructor available in android.database.sqlite.SQLitepenhelper\" along with o

2条回答
  •  梦毁少年i
    2021-01-17 17:08

    You need to define an explicit constructor yourself that calls the 4- or 5-arg super constructor in SQLiteOpenHelper.

    For example:

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

    where database.db is your database file name and 1 is the version.

提交回复
热议问题