ORMLite在Android上没有要求的onCreate [英] ORMLite on Android not calling onCreate

查看:280
本文介绍了ORMLite在Android上没有要求的onCreate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ORMLite v 4.40,我试图让我的应用程序运行,但它似乎忽略OnCreate函数

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

我的DatabaseHelper看起来是这样的(片段式的)

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

我MainActivity调用DatabaseHelper描述:

My MainActivity calls the DatabaseHelper as described:

public class MainActivity extends OrmLiteBaseActivity<ORMLiteHelper>  {

我曾尝试重新安装应用程序,升级数据库版本,没有任何工程。 我看到的构造函数调用(包括错字:-)的的onCreate和onUpgrade但不叫。

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.

pciated任何帮助AP $ P $

Any help appreciated

巴里

推荐答案

创建 ORMLiteHelper 的实例并调用 getWritableDatabase()。如果没有创建数据库,然后的onCreate将被调用。

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

这篇关于ORMLite在Android上没有要求的onCreate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆