Reputation: 151
I'm getting the
'This class should provide a default constructor'
error when i'm trying to build the APK
this is my DBHelper class:
public class DBHelper extends SQLiteOpenHelper {
// create variables
public DBHelper(Context context)
{
super(context, DATABASE_NAME , null, 1);
}
// onCreate
I was under the impression that
public DBHelper(Context context)
was the default constructor? And have checked other answers with this and can't find anything to help...
Thanks in advance
Upvotes: 5
Views: 253
Reputation: 1
As the error suggest
Error: This class should provide a default constructor (a public constructor with no arguments)
try this way:
public class DBHelper extends SQLiteOpenHelper {
// create variables
public DBHelper(){
super();
}
public DBHelper(Context context)
{
super(context, DATABASE_NAME , null, 1);
}
// onCreate
Upvotes: -1
Reputation: 3636
A default constructor is a constructor without any arguments.
SQLiteOpenHelper
needs at least a context so you won't be able to create a default constructor for your DBHelper
. Are you sure this is the class causing this error ?
Upvotes: 2