Home » Android » ORMLite on Android not calling onCreate

ORMLite on Android not calling onCreate

Posted by: admin June 15, 2020 Leave a comment


Using ORMLite v 4.40, I try to get my app running, but it seems to ignore the onCreate function

My DatabaseHelper looks like this (snippet style)

public class ORMLiteHelper extends  OrmLiteSqliteOpenHelper {

    private Context databaseContext;
    private static String DATABASE_NAME = "InVinoVeritas";
    private static int DATABASE_VERSION = 1; 

    public ORMLiteHelper(Context context) {
        super (context, DATABASE_NAME, null, DATABASE_VERSION);
        Log.v("ORMLiteHelper", "Cosntructor");

    public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
        Log.v("DatabaseHelper", "onCreate");
    public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
            Log.v("DatabaseHelper", "onUpgrade");

My MainActivity calls the DatabaseHelper as described:

public class MainActivity extends OrmLiteBaseActivity<ORMLiteHelper>  {

I have tried re-installing the application, upgrading the database version, nothing works.
I do see the constructor call (including typo :-), the onCreate and onUpgrade however are not called.

Any help appreciated


How to&Answers:

Create instance of ORMLiteHelper and call getWritableDatabase(). When database is not created then onCreate will be invoked.