I am currently using Android studio 1.1.0.
My project builds successfully. however, when i try to create signed APK, I see the following message: Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.example.app.Dblogic) [Instantiatable]
I have seen many folks suggesting me to create an empty constructor. However, my class Dblogic extends SQLiteOpenHelper. When i create and empty constructor for Dblogic, i see the message: there is no default constructor available in android.database.sqlite.sqliteopenhelper
It seems like a catch-22 situation. Appreciate your help!
Code:
package com.example.app;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class Dblogic extends SQLiteOpenHelper {
static final String DATABASE_NAME = "sweet.db";
private static final int DATABASE_VERSION = 1;
static final String TABLE_NAME1 = "tb_sweet";
private SQLiteDatabase database;
public Dblogic() {
}
public Dblogic(Context context) {
//public Dblogic() {
//super(context, DATABASE_NAME, null, DATABASE_VERSION);
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE "+ TABLE_NAME1 + " ( " + "_id INTEGER PRIMARY KEY AUTOINCREMENT, Date TEXT NOT NULL, Name TEXT NOT NULL, Description TEXT NOT NULL, Image BLOB);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME1);
onCreate(db);
}
public void openDB() throws SQLException {
database = getWritableDatabase();
}
public void closeDB() {
database.close();
}
public long insertQuery(ContentValues cValues) {
return database.insert(TABLE_NAME1, null, cValues);
}
}
Aucun commentaire:
Enregistrer un commentaire