I have two different falvours in my Androdi app that should use different SQL implementations. One use:
android.database.sqlite.SQLiteDatabase
and second:
net.sqlcipher.database.SQLiteDatabase
I have methods like that:
getAll(SQLiteDatabase conn)
How should I solve this situation to avoid copy&paste? What is the best pratcice? I have few ideas: first one (the worst with a lot of copypaste) is to provide different methods :
getAll(android.database.sqlite.SQLiteDatabase conn)
getAll(net.sqlcipher.database.SQLiteDatabase conn)
second is to wrap this class with some other in every flavour importing proper database(aggregation, composition as SQLiteDatabase is final):
import android.database.sqlite.SQLiteDatabase;
public class SQLliteDatabaseFlavoured {
SQLiteDatabase sqLiteDatabase;
}
With usage:
getAll(SQLliteDatabaseFlavoured.SQLiteDatabase conn)