Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORMLite on Android not calling onCreate

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");
    ...

    @Override
    public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
        Log.v("DatabaseHelper", "onCreate");
    ...
    @Override
    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

Barry

like image 987
barrel Avatar asked Jun 06 '12 19:06

barrel


1 Answers

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

like image 173
pawelzieba Avatar answered Nov 15 '22 22:11

pawelzieba