简体   繁体   English

Android和Ormlite:在CreateCreate的DatabaseHelper中插入数据

[英]Android & Ormlite: Inserting data in DatabaseHelper onCreate

I am using Ormlite for the first time and I am trying to setup my DatabaseHelper to insert rows after creating the database's tables. 我是第一次使用Ormlite,并且试图将我的DatabaseHelper设置为在创建数据库表之后插入行。 I am getting a getWritableDatabase called recursively error when I do. 执行此操作时,我得到一个getWritableDatabase called recursively错误。

Here is my onCreate: 这是我的onCreate:

public void onCreate(SQLiteDatabase sqliteDatabase, ConnectionSource connectionSource) {

    try {
        TableUtils.createTable(databaseType, connectionSource, User.class);

        // Add test user
        User test = new User("test", "12345");
        getUserDao().create(test);


    } catch (SQLException e) {
        Log.e(DatabaseHelper.class.getName(), "Unable to create databases", e);
    }
}

The problem here was that @karnage was using an older version of ORMLite that had a bug with using the DAOs in the onCreate -- the pattern that he is using. 这里的问题是@karnage使用的是旧版本的ORMLite ,该版本在onCreate中使用DAO时存在错误-他正在使用的模式。 This was fixed in version 4.6 (10/2010) and downloading and running the latest version works for him. 此问题已在4.6版(10/2010)中修复,下载并运行最新版本适用于他。

Here is the bug report: 错误报告如下:

https://sourceforge.net/tracker/?func=detail&aid=3117883&group_id=297653&atid=1255989 https://sourceforge.net/tracker/?func=detail&aid=3117883&group_id=297653&atid=1255989

Here's the change log file to track new features and versions of ORMLite : 这是更改日志文件,用于跟踪ORMLite的新功能和版本:

http://ormlite.com/changelog.txt http://ormlite.com/changelog.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM