ORMLite on Android not calling onCreate

江枫思渺然 提交于 2019-12-09 16:28:45

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/10920911/ormlite-on-android-not-calling-oncreate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!