I'd like to extend SQLiteDataBase class to be able to override some methods (like rawQuery, execSQL, ...) with the purpouse of doing some statistics about queries execution times.
There are hundreds of places where I call those functions. So, creating a derived class from the base class SQLiteDatabase will help me a lot!
The problem is: when extending SQLiteDataBase, it can't find any constructor from the super class.
import android.database.sqlite.SQLiteDatabase;
public class MySQLiteDatabase extends SQLiteDatabase
{
MySQLiteDatabase()
{
super(); // <<<--- can't find any visible constructor
}
}
There are hundreds of places where I call thoses functions. So, creating a derived class from the base class SQLiteDatabase will help me a lot!.
You can't extend the SQLiteDatabase
as it's declared final
and you can't extend a final
class in java.
An alternative is to make a "wrapper" SQLiteDatabase
which will replicate the SQLiteDatabase
class with its methods and insert the measurement logic in the wrapper methods:
public class SQLiteDatabaseWrapper {
private SQLiteDatabase mDatabase;
public void initDatabase() {
//obtain the database here and assign it to mDatabase
}
// replicate the SQLiteDatabase methods
public void execSQL(String sql) {
//insert whatever logic you have for measurement
// do the measurement
mDatabase.execSQL(sql);
}
// other methods from SQLiteDatabase
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With